Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve :check_origin docs. #6062

Merged
merged 1 commit into from
Jan 23, 2025

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! 🙌🏻

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