-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: resolve CORS issues via reverse proxy configuration (Vite, Nginx, Apache) #4880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c14c5e9
7422f3c
9a8f620
620c42c
9ce303c
f4f916a
077878d
bbe96c4
bbfbadc
01cf5d0
992944d
965b2dc
204e3fc
3ce3fa8
baed561
ec88c45
0f8cd17
d66d892
feb6b2b
67c4c1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <VirtualHost *:80> | ||
| ServerName localhost | ||
palisadoes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| DocumentRoot /usr/share/nginx/html | ||
|
||
|
|
||
| # Proxy GraphQL requests to the internal API container | ||
| ProxyPass /graphql http://api:4000/graphql | ||
| ProxyPassReverse /graphql http://api:4000/graphql | ||
palisadoes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Handle WebSocket upgrades | ||
| RewriteEngine On | ||
| RewriteCond %{HTTP:Upgrade} =websocket [NC] | ||
| RewriteRule /graphql/(.*) ws://api:4000/graphql/$1 [P,L] | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Serve React App (Fallback to index.html for routing) | ||
| <Directory /usr/share/nginx/html> | ||
| Options Indexes FollowSymLinks | ||
| AllowOverride All | ||
| Require all granted | ||
| FallbackResource /index.html | ||
| </Directory> | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </VirtualHost> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,15 @@ If you are trying to access Talawa Admin from a remote host with the API URL con | |
| REACT_APP_TALAWA_URL="http://YOUR-REMOTE-ADDRESS:4000/graphql" | ||
|
|
||
| ``` | ||
| :::tip Proxy Configuration | ||
| To avoid CORS issues when hosting the Admin and API on different IP addresses, you can use a **relative path** for the backend URL. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the documentation to reflect the distributed system perspective, clarifying that the Web Server must be configured to proxy traffic to the API IP. |
||
| Talawa-Admin includes a pre-configured Reverse Proxy (via Vite in Dev, and Nginx/Apache in Prod). | ||
|
|
||
| **Recommended Configuration:** | ||
| ```bash | ||
| REACT_APP_TALAWA_URL=/graphql | ||
| REACT_APP_BACKEND_WEBSOCKET_URL=/graphql | ||
|
||
|
|
||
| #### Setting up REACT_APP_BACKEND_WEBSOCKET_URL in .env file | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.