Add production-like local Docker edge stack for docs + API#7
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24fc62faed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| map $http_origin $cors_origin { | ||
| default ""; | ||
| "http://example.com" "http://example.com"; | ||
| "https://example.com" "https://example.com"; | ||
| "http://localhost:3000" "http://localhost:3000"; |
There was a problem hiding this comment.
Permit localhost origin for edge-served docs
The CORS map allows http://localhost:3000 but not http://localhost, even though this same file defines a server_name localhost edge route for docs. When users open docs via http://localhost and the UI calls http://api.example.com, the browser sends Origin: http://localhost; that falls through to default "", so Access-Control-Allow-Origin is empty and the request is blocked by CORS. Adding http://localhost to the map avoids breaking the localhost edge workflow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a06c844. Added http://localhost to the CORS origin map so the localhost edge workflow (Host: localhost docs -> api.example.com) returns a valid Access-Control-Allow-Origin header. Also re-ran a preflight check with Origin: http://localhost and it now returns 204 with the expected CORS header.
Summary
web/Dockerfile) with a lightweight static server (web/server.mjs) for Astro build outputdocker-compose.ymlwith anedgenginx service routingexample.comto docs andapi.example.comto the APIdocker/nginx/local-edge.confplus README guidance for hosts mapping and explicitly documented local-dev allowances (localhost:3000,localhost:8080, and/api/*fallback)Test Plan
docker compose configdocker compose build docs apidocker compose up -dthencurl -H 'Host: example.com' http://127.0.0.1/returns docs HTMLdocker compose up -dthencurl -H 'Host: api.example.com' 'http://127.0.0.1/now?format=iso'returns timestampapi.example.comreturns204with allow-origin header forhttp://example.com