Events 3.6.1: branding uploads work behind a proxy with extension rules
The logo/favicon upload succeeded, but the check that the site can show it got a 404: on events-demo every /api/... path ending in a file extension (.png, .ico, .pdf, .json) went to Next.js instead of the backend. - next.config.ts: /api/* and /uploads/* that reach the site are passed to the backend (beforeFiles rewrites) via the new BACKEND_INTERNAL_URL (http://127.0.0.1:<apiPort>, from env.template.json on deploy). The e2e E2E_API_PROXY uses the same rewrites. - nginx written by both installers and shown in DEPLOYMENT.md: /api/ and /uploads/ use location ^~ so no regex location can take them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,7 +116,7 @@ else
|
||||
echo " backend/.env exists — kept"
|
||||
fi
|
||||
if [ ! -f "$DIR/frontend/.env.production" ]; then
|
||||
echo "NEXT_PUBLIC_API_URL=$SITE_URL" > "$DIR/frontend/.env.production"
|
||||
printf 'NEXT_PUBLIC_API_URL=%s\nBACKEND_INTERNAL_URL=http://127.0.0.1:%s\n' "$SITE_URL" "$API_PORT" > "$DIR/frontend/.env.production"
|
||||
fi
|
||||
if [ ! -f "$DIR/ecosystem.config.js" ]; then
|
||||
sed -e "s/'hope-events-backend'/'$NAME-backend'/" -e "s/'hope-events-frontend'/'$NAME-frontend'/" -e "s/-p 3000/-p $WEB_PORT/" \
|
||||
@@ -140,14 +140,17 @@ server {
|
||||
server_name $DOMAIN;
|
||||
client_max_body_size 25m;
|
||||
|
||||
# For the backend locations below ("location /" sets its own).
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
|
||||
# The API, uploaded files, health and API docs go to the backend; everything else to the site.
|
||||
location ~ ^/(api|uploads|health|docs)(/|\$) {
|
||||
proxy_pass http://127.0.0.1:$API_PORT;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
}
|
||||
# ^~ so a regex location added later (e.g. caching *.png) can't send /api/…/logo.png to the site.
|
||||
location ^~ /api/ { proxy_pass http://127.0.0.1:$API_PORT; }
|
||||
location ^~ /uploads/ { proxy_pass http://127.0.0.1:$API_PORT; }
|
||||
location ~ ^/(api|uploads|health|docs)(/|\$) { proxy_pass http://127.0.0.1:$API_PORT; }
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:$WEB_PORT;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
Reference in New Issue
Block a user