Skip to content

Commit dc96a36

Browse files
authored
Add CORS workaround for local development
1 parent 8ad3c50 commit dc96a36

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

DEVELOPMENT.md

+15
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,28 @@ pip install .
7070
cd ..
7171
mondey-backend
7272
```
73+
(run the last command above in the `mondey/mondey-backend` folder itself)
74+
75+
7376

7477
3. install and run the frontend development server:
7578

79+
3.1: Run the frontend
7680
```sh
7781
cd frontend
7882
pnpm install
7983
pnpm run dev
8084
```
8185

8286
The website is then served at http://localhost:5173/.
87+
88+
3.2: If you encounter CORS/login/API connection from frontend issues, do the below: Implement this CORS workaround so your frontend and backend requests connect after login (if you see HTTP 401 or "Unauthorised", it could be CORS)
89+
90+
3.2.1: Add the below code to `vite.config.ts` in the existing 'server' section after "strictPort: true":
91+
```
92+
proxy: {
93+
'/api': 'http://localhost:8000',
94+
},
95+
```
96+
97+
3.2.2: And set `VITE_MONDEY_API_URL=http://localhost:5173/api` in `/frontend/.env`

frontend/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# api location for local development:
2-
VITE_MONDEY_API_URL=http://localhost:8000/api
2+
VITE_MONDEY_API_URL=http://localhost:5173/api

frontend/vite.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ export default defineConfig({
1212
host: "localhost",
1313
port: 5173,
1414
strictPort: true,
15+
proxy: {
16+
"/api": "http://localhost:8000",
17+
},
1518
},
1619
});

0 commit comments

Comments
 (0)