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: examples/social-demo/README.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,13 +90,13 @@ Add these extra fields to the `users` schema:
90
90
```env
91
91
VITE_PUBLIC_KEY=pk_live_your_key_here
92
92
VITE_API_URL=https://api.ub.bitbros.in
93
-
# Required for image uploads only
93
+
# Required for image uploads and GitHub social auth start
94
94
VITE_PROXY_URL=http://localhost:4000/api/proxy
95
95
```
96
96
97
97
**Server (`server/.env`)**
98
98
```env
99
-
# Used only by upload proxy (/storage/*)
99
+
# Used by the local proxy for uploads and social auth start
100
100
API_KEY=sk_live_your_key_here
101
101
PORT=4000
102
102
```
@@ -129,6 +129,7 @@ In GitHub:
129
129
5. Copy the generated `Client ID` and `Client Secret` into urBackend Auth settings.
130
130
131
131
No extra client `.env` variables are required for GitHub social auth. The redirect target comes from your urBackend project `Site URL`.
132
+
The local `server` must be running because the demo starts GitHub OAuth through the proxy so it can attach the required API key header.
132
133
133
134
### 5. Run the Application
134
135
```bash
@@ -162,11 +163,12 @@ social-demo/
162
163
This demo is now **PK-first** and aligned with the latest public APIs:
163
164
1.**Public API Client**: Uses `pk_live_*` for `/api/userAuth/*` and `/api/data/*`.
164
165
2.**RLS-protected writes**: `posts`, `comments`, `likes`, `follows`, and `profiles` require RLS so authenticated users can write with `pk_live`.
165
-
3.**Upload Proxy**: A tiny local server keeps `sk_live_*` only for `/api/storage/*` uploads.
166
+
3.**Upload Proxy**: A tiny local server keeps `sk_live_*` only for `/api/storage/*` uploads and starts social auth safely.
166
167
167
168
### Social auth flow in this demo
168
169
169
-
- The client sends users to `GET /api/userAuth/social/github/start` with the public key.
170
+
- The client sends users to the local proxy route `GET /api/proxy/userAuth/social/github/start`.
171
+
- The proxy attaches your configured API key and forwards the request to urBackend.
170
172
- urBackend handles the GitHub OAuth redirect and sends users back to `<siteUrl>/auth/callback`.
171
173
- The callback page exchanges the one-time `rtCode` for a refresh token, stores both tokens, and loads the signed-in user.
172
174
@@ -248,6 +250,7 @@ For each writable collection (`posts`, `comments`, `likes`, `follows`, `profiles
248
250
-**Profile/search pages empty?** Ensure `profiles` collection exists and RLS is enabled with `ownerField=userId`.
249
251
-**403 on create/update/delete?** Ensure RLS is enabled on that collection for `pk_live` writes.
250
252
-**Images not uploading?** Ensure the `server` is running and `API_KEY` is a secret key (`sk_live_...`) for `/storage/*`.
253
+
-**GitHub button shows `API key not found`?** Make sure the local `server` is running and `VITE_PROXY_URL` points to it. The demo starts GitHub OAuth through the proxy, not directly from the browser.
251
254
-**403 Forbidden?** Double-check your **Domain Whitelisting** settings in the urBackend dashboard.
252
255
-**Data not appearing?** Verify that your collection names and field types match the schemas above exactly.
253
256
-**GitHub login redirects back but does not sign in?** Make sure your urBackend project `Site URL` exactly matches the demo origin, usually `http://localhost:5173`.
0 commit comments