Skip to content

Commit 4b92413

Browse files
authored
Improve :check_origin docs. (#6062)
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
1 parent 5dba0bb commit 4b92413

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/phoenix/endpoint.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ defmodule Phoenix.Endpoint do
828828
if so, the level
829829
830830
* `:check_origin` - if the transport should check the origin of requests when
831-
the `origin` header is present. May be `true`, `false`, a list of hosts that
831+
the `origin` header is present. May be `true`, `false`, a list of URIs that
832832
are allowed, or a function provided as MFA tuple. Defaults to `:check_origin`
833833
setting at endpoint configuration.
834834
@@ -839,8 +839,8 @@ defmodule Phoenix.Endpoint do
839839
Only use in development, when the host is truly unknown or when
840840
serving clients that do not send the `origin` header, such as mobile apps.
841841
842-
You can also specify a list of explicitly allowed origins. Wildcards are
843-
supported.
842+
You can also specify a list of explicitly allowed origins. Each origin may include
843+
scheme, host, and port. Wildcards are supported.
844844
845845
check_origin: [
846846
"https://example.com",

0 commit comments

Comments
 (0)