Skip to content

Improve :check_origin docs.#6062

Merged
SteffenDE merged 1 commit intophoenixframework:mainfrom
leandrocp:lp-fix-check-origin-docs
Jan 23, 2025
Merged

Improve :check_origin docs.#6062
SteffenDE merged 1 commit intophoenixframework:mainfrom
leandrocp:lp-fix-check-origin-docs

Conversation

@leandrocp
Copy link
Contributor

Realized that passing only a host to :check_origin is not enough as the doc suggest, since it might also check scheme, host, and port against a URI.

So this was not really working: check_origin: ["my-app.fly.dev"]
I had to include the scheme as well: check_origin: ["https://my-app.fly.dev"]

The examples are clear but the rest of the doc is a bit misleading.

See

compare?(origin_scheme, allowed_scheme) and
compare?(origin_port, allowed_port) and
compare_host?(origin_host, allowed_host)

Realized that passing only a host to `:check_origin` is not enough as the doc suggest,
since it might also check scheme, host, and port against a URI.

So this was not really working: `check_origin: ["my-app.fly.dev"]`
I had to include the scheme as well: `check_origin: ["https://my-app.fly.dev"]`.

The examples are clear but the rest of the doc is a bit misleading.

See https://github.com/phoenixframework/phoenix/blob/5dba0bb6216e26fe5c48aafebad64d5f96da8868/lib/phoenix/socket/transport.ex#L616-L618
@SteffenDE SteffenDE merged commit 4b92413 into phoenixframework:main Jan 23, 2025
5 checks passed
@SteffenDE
Copy link
Contributor

Thank you! 🙌🏻

@leandrocp leandrocp deleted the lp-fix-check-origin-docs branch January 31, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants