Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/broadcastand/api/broadcast/:topic/events/:event, answered byCorsicawithorigins: "*"andallow_headers: :allWhy
The broadcast REST endpoints pipe through
:open_cors(Corsica, origins: "*", from #693), but Phoenix runs a pipeline only after a route matches. There is no OPTIONS route, so a browser's preflight getsPhoenix.Router.NoRouteError(404) with no CORS headers, and the browser never sends the POST. Corsica's docs call out this case. Even if the pipeline ran,allow_headersdefaults to[], so a preflight asking forapikey,authorizationorcontent-typewould still be refused.This doesn't show up behind a gateway that answers preflights itself (Kong in the hosted and self-hosted stacks). It does for a browser app calling standalone Realtime from another origin, for example the local dev setup.
The POST routes and their pipelines are unchanged. The tenant and auth plugs don't run for OPTIONS.
passthrough_non_cors_requests: truemakes these OPTIONS-only routes answer 200 when there's noOriginheader instead of leaving the conn unsent.Validation
origin/main(ce84f7d7) with404andno route found for OPTIONS /api/broadcast...test/realtime_web/router_test.exs2 passed. Each run on its own:broadcast_controller_test.exs13,broadcast_single_controller_test.exs34,openapi_controller_test.exs2,page_controller_test.exs7,plugs/auth_tenant_test.exs14,plugs/assign_tenant_test.exs4 passedmix format --check-formatted,MIX_ENV=test mix credo --stricton the changed files,git diff --checkmix compile --force --warnings-as-errors,MIX_ENV=test mix compile --warnings-as-errorsandmix format --check-formattedwith the CI-pinned Elixir 1.19.5 / OTP 28 (elixir:1.19.5-otp-28container)I didn't run the full suite or dialyzer locally.