frappe_docker/overrides/compose.local-origin.yaml
abounoone 4e2516cdd7 fix: socket.io Invalid origin + dev mode PYTHONPATH + sync-assets improvements
- compose.local-origin.yaml: patch nginx to forward Host: $http_host (not
  websocket:9000) in /socket.io block so authenticate.js host==origin check passes
- compose.picking-dev.yaml: add PYTHONPATH=/home/frappe/frappe-bench/apps/picking_app
  to all services so picking_app is importable without pip install in dev mode
- images/custom/Containerfile: fix Frappe bug — add missing return after
  next(new Error("Invalid namespace")) in socket.io authenticate middleware
- Makefile: recreate-frontend target; sync-assets clears cache before copy and
  uses --force-recreate instead of restart; dev-up force-recreates frontend to
  flush stale backend IPs from nginx cache

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 10:21:20 +00:00

24 lines
1.1 KiB
YAML

services:
frontend:
# Fix socket.io "Invalid origin" when accessing via localhost.
# By default nginx forces "Origin: http://erp.local" for websocket proxying,
# but the browser sends Host: localhost:8090 — they don't match.
# Strategy: run nginx-entrypoint.sh to generate /etc/nginx/conf.d/frappe.conf,
# then patch the generated file (template dir is read-only), then start nginx.
entrypoint:
- bash
- -c
- |
nginx-entrypoint.sh &
NGINX_PID=$$!
sleep 1
sed -i 's|proxy_set_header Origin .*|proxy_set_header Origin $$http_origin;|' \
/etc/nginx/conf.d/frappe.conf
sed -i '/location \/socket\.io/,/proxy_pass/{s|proxy_set_header Host .*|proxy_set_header Host $$http_host;|}' \
/etc/nginx/conf.d/frappe.conf
sed -i 's|listen 8080;|listen 8080;\n\tresolver 127.0.0.11 valid=30s;|' \
/etc/nginx/conf.d/frappe.conf
sed -i 's|proxy_pass http://socketio-server;|set $$sock websocket:9000;\n\t\tproxy_pass http://$$sock;|' \
/etc/nginx/conf.d/frappe.conf
nginx -s reload
wait $$NGINX_PID