Skip to content

Commit 9ce303c

Browse files
committed
fix: address review comments
1 parent 620c42c commit 9ce303c

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PORT=4321
88

99
# Run Talawa-api locally in your system, and put its url into the same.
1010

11-
REACT_APP_TALAWA_URL=/graphql
11+
REACT_APP_TALAWA_URL=http://localhost:4000/graphql
1212

1313
# Do you want to setup and use "I'm not a robot" Checkbox (Google Recaptcha)?
1414
# If no, leave blank, else write yes
@@ -24,7 +24,7 @@ REACT_APP_USE_RECAPTCHA=
2424
REACT_APP_RECAPTCHA_SITE_KEY=
2525

2626
# has to be inserted in the env file to use websocket based features.
27-
REACT_APP_BACKEND_WEBSOCKET_URL=/graphql
27+
REACT_APP_BACKEND_WEBSOCKET_URL=ws://localhost:4000/graphql
2828

2929
# If you want to logs Compiletime and Runtime error , warning and info write YES or if u want to
3030
# keep the console clean leave it blank

config/docker/setup/apache.conf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
<VirtualHost *:80>
2+
# CHANGE THIS: Update 'localhost' to your real domain name in production
23
ServerName localhost
3-
DocumentRoot /usr/share/nginx/html
4+
5+
# Standard Apache web root
6+
DocumentRoot /usr/local/apache2/htdocs
47

58
# Proxy GraphQL requests to the internal API container
9+
# 'api' is the Docker Service Name defined in docker-compose.yml.
10+
# If running outside Docker, replace 'api' with your API IP address.
611
ProxyPass /graphql http://api:4000/graphql
712
ProxyPassReverse /graphql http://api:4000/graphql
813

9-
# Handle WebSocket upgrades (FIXED REGEX)
14+
# Handle WebSocket upgrades
1015
RewriteEngine On
1116
RewriteCond %{HTTP:Upgrade} =websocket [NC]
1217
RewriteRule ^/graphql(.*)$ ws://api:4000/graphql$1 [P,L]
1318

14-
# Serve React App (FIXED SECURITY)
15-
<Directory /usr/share/nginx/html>
19+
# Serve React App
20+
<Directory /usr/local/apache2/htdocs>
1621
Options FollowSymLinks
1722
AllowOverride None
1823
Require all granted

config/docker/setup/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ server {
1010
}
1111

1212
location /graphql {
13+
# 'api' is the Docker Service Name defined in docker-compose.yml.
14+
# If running outside Docker, replace 'api' with your API IP address.
1315
proxy_pass http://api:4000;
1416

1517

config/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default defineConfig({
6363
port: PORT,
6464
proxy: {
6565
'/graphql': {
66-
target: process.env.VITE_API_URL || 'http://localhost:4000',
66+
target: 'http://localhost:4000',
6767
changeOrigin: true,
6868
ws: true,
6969
},

docs/docs/docs/getting-started/configuration.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,21 @@ If you are trying to access Talawa Admin from a remote host with the API URL con
6868
REACT_APP_TALAWA_URL="http://YOUR-REMOTE-ADDRESS:4000/graphql"
6969
7070
```
71-
:::tip Proxy Configuration
72-
To avoid CORS issues when hosting the Admin and API on different IP addresses, you can use a **relative path** for the backend URL.
7371

74-
Talawa-Admin includes a pre-configured Reverse Proxy (via Vite in Dev, and Nginx/Apache in Prod).
72+
#### Reverse Proxy Configuration (CORS Solution)
73+
To resolve CORS issues in production environments (where Admin and API run on different IPs), Talawa-Admin is designed to use a **Reverse Proxy**.
7574

76-
**Recommended Configuration:**
75+
**1. React Configuration:**
7776
```bash
7877
REACT_APP_TALAWA_URL=/graphql
7978
REACT_APP_BACKEND_WEBSOCKET_URL=/graphql
79+
```
80+
**2. Web Server Configuration:**
81+
You must configure your web server (Nginx/Apache) to forward these `/graphql` requests to the actual API IP address.
82+
83+
- **Docker**: The provided nginx.conf and apache.conf are pre-configured to forward to the internal api container.
84+
85+
- **Distributed Systems:** If running on bare metal, update the proxy_pass directive in nginx.conf (or Apache equivalent) to point to your actual API IP Address.
8086

8187
#### Setting up REACT_APP_BACKEND_WEBSOCKET_URL in .env file
8288

0 commit comments

Comments
 (0)