Getting following error whenever I access https://team_abc.dev.myapp.me/
This issue might be specific for subdomains. Not very sure in what other contexts this issue arrises.
07:26:06.498 [error] Could not check origin for Phoenix.Socket transport.
This happens when you are attempting a socket connection to
a different host than the one configured in your config/
files. For example, in development the host is configured
to "localhost" but you may be trying to access it from
"127.0.0.1". To fix this issue, you may either:
1. update [url: [host: ...]] to your actual host in the
config file for your current environment (recommended)
2. pass the :check_origin option when configuring your
endpoint or when configuring the transport in your
UserSocket module, explicitly outlining which origins
are allowed:
check_origin: ["https://example.com",
"//another.com:888", "//other.com"]
07:26:20.174 [error] Could not check origin for Phoenix.Socket transport.
This happens when you are attempting a socket connection to
a different host than the one configured in your config/
files. For example, in development the host is configured
to "localhost" but you may be trying to access it from
"127.0.0.1". To fix this issue, you may either:
I have following in my endpoint.ex
plug Plug.Session,
store: :cookie,
key: "_myapp_key",
signing_salt: "RHWasYaA",
domain: ".dev.myapp.me"
and following in my prod.exs
http: [port: {:system, "PORT"}],
url: [host: "dev.myapp.me", port: 80]
I have also added in prod.exs
config :myapp, MyApp.Endpoint,
check_origin: ["https://dev.myapp.me", "https://myapp.me"]
Any way to solve this issue? Thanks.
You should add all domains that resolve to your host in the check_origin:
check_origin: [..., "//team_abc.dev.myapp.me"]
EDIT:
After reading the source code for the check_origin functionality, it seems like it should be possible to set a wildcard domain name like this:
check_origin: [..., "//*.myapp.me"]
More details: https://github.com/phoenixframework/phoenix/blob/da9f7653b9daf29a4c415be52a19ee6f4473e083/lib/phoenix/socket/transport.ex#L444
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With