You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: firebase/README.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ See the screen recording at `./screen_recording.gif` or Open this example on [Co
10
10
11
11
[](https://codesandbox.io/s/github/remix-run/examples/tree/main/firebase)
12
12
13
-
## Example
13
+
## Running locally
14
14
15
15
To run it, you need to either:
16
16
@@ -31,15 +31,25 @@ When the SERVICE_ACCOUNT and CLIENT_CONFIG environment variables have not been s
31
31
32
32
When you run `npm run emulators`, an initial user is created with credentials `user@example.com:password`. This can be configured in `firebase-fixtures/auth/accounts.json` or via the emulator UI.
33
33
34
-
## Auth (`app/server/auth.server.ts`)
34
+
## Deploying
35
+
36
+
1. Follow the "Run against a Firebase Project" steps above if not done already
37
+
2. Install the Firebase CLI with `npm i -g firebase-tools`
38
+
3. Log in to the CLI with `firebase login`
39
+
4. Run `firebase use --add` and choose the Firebase project you want to deploy to
40
+
5. Deploy with `firebase deploy`
41
+
42
+
## Details
43
+
44
+
### Auth (`app/server/auth.server.ts`)
35
45
36
46
`signIn` returns a Firebase session-cookie-string, when sign-in is successfull. Then Remix `cookieSessionStorage` is used to set, read and destroy it.
37
47
38
48
`signUp` creates a user and calls sign-in to receive the session cookie.
39
49
40
50
`requireAuth` uses `firebase-admin` to verify the session cookie. When this check fails, it throws a `redirect` to the login page. Use this method to protect loaders and actions. The returned `UserRecord` can be handy to request or manipulate data from the Firestore for this user.
41
51
42
-
## Firestore (`app/server/db.server.ts`)
52
+
###Firestore (`app/server/db.server.ts`)
43
53
44
54
Requests to the Firestore are made using the `firebase-admin`-SDK. You need to check validity of your requests manually, since `firestore.rules` don't apply to admin requests.
0 commit comments