lmletham

lmletham

Hey guys!

I have deployed my Phoenix project to Fly here and set up my DNS records and certs in order to connect to my custom domain here but something is broken.

The fly.dev url works perfectly, but even though my custom domain displays my test text it also throws a “Something went wrong” error..

Fly.io logs say this:

[error] Could not check origin for Phoenix.Socket transport.
[info] Origin of the request: https://wordsmith.pub
[info] This happens when you are attempting a socket connection to
[info] a different host than the one configured in your config/
[info] files. For example, in development the host is configured
[info] to “localhost” but you may be trying to access it from
[info] “127.0.0.1”. To fix this issue, you may either:
[info] 1. update [url: [host: …]] to your actual host in the
[info] config file for your current environment (recommended)
[info] 2. pass the :check_origin option when configuring your
[info] endpoint or when configuring the transport in your
[info] UserSocket module, explicitly outlining which origins
[info] are allowed:
[info] check_origin: [“https://example.com”,
[info] “//another.com:888”, “//other.com”]

I tried to do step 1 by changing the config.exs file in my Phoenix project to add url: [host: "wordsmith.pub"], but that didn’t fix anything and I don’t know how to do the second suggestion.

I didn’t see any documentation on Fly indicating I would have to change my Phoenix files in order to deploy to a custom domain, so I’m not sure what to try next.

My first thought is that this is some kind of DNS record propagation issue. I added the certs and DNS records pointing to the custom domain yesterday morning. So let me know if I simply need to wait longer!

Thanks!

Showing Posts 1 to 5

pdgonzalez872

pdgonzalez872

add check_origin: ["https://wordsmith.pub"] under the url key in the endpoint configuration.

pdgonzalez872

pdgonzalez872

Also, in the docs they mention setting a CNAME as the simplest route.

is there any reason you didn’t go that route? That’s what I’ve done a couple of times.

Your original issue will be fixed with the check_origin key though :slight_smile:

lmletham

lmletham OP

Pretty sure I tried the CNAME option first and messed it up haha so I thought it didn’t work for me. So to answer your question, inexperience.

Thanks for the idea! I actually just tried one last thing and got it working by going into the fly.toml file and changing the PHX_HOST variable from the fly.dev server to my “wordsmtih.pub” domain. Reran fly deploy and it seems to be working beautifully.

Thanks for the suggestion! We can probably mark this thread closed.

lmletham

lmletham OP

I was too hasty in calling it solved!

Changing the PHX_HOST variable to “Wordsmith.pub” definitely fixed by custom domain, but at the cost of breaking the “wordsmith-lml.fly.dev” one.

I was able to get the fly.dev one back working though by adding your check origin suggestion.

In my Phoenix Project, config/config.exs file I added both URLs:

config :wordsmith, WordsmithWeb.Endpoint,
  url: [host: "localhost"],
  check_origin: ["https://wordsmith.pub","https://wordsmith-lml.fly.dev"],
  adapter: Bandit.PhoenixAdapter,
  render_errors: [
    formats: [html: WordsmithWeb.ErrorHTML, json: WordsmithWeb.ErrorJSON],
    layout: false
  ],
  pubsub_server: Wordsmith.PubSub,
  live_view: [signing_salt: "E1HLgpGK"]

So the current state is:

  • PHX_HOST variable in the fly.toml file is set to “wordsmith.pub”
  • I added both URLs to a check origin line.

Let me know if that is totally unkosher! It seems to be working.

natewallis

natewallis

I thought using @ for CNAME wasn’t a good idea since that stops you creating other records on the apex. Maybe there instructions have changed since this was last posted as it seems the advice now is to point A and AAAA to the ipv4 and ipv6 addresses respectively and then use a CNAME for www to point to the fly dev address..

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
psy-q
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews