stoiven

stoiven

Assets not loading when deploying to Heroku

Hi there! I have deployed this (after forking) to Heroku, but for some reason, none of the assets are loading. I’m fairly new to the language and I have a feeling that maybe some environmental variable might be misconfigured or something?

The front page loads perfectly fine, but not as intended. I went to check the developer tools and realized that it was doing a GET call from localhost, which I don’t believe is right?

GET http://localhost:43751/css/app-b358ab485f4965187a0366829058b5e7.css?vsn=d net::ERR_CONNECTION_REFUSED

GET http://localhost:43751/js/app-47ffdb6029e02e02cf2f5c4f4e2c7e4e.js?vsn=d net::ERR_CONNECTION_REFUSED

localhost:43751/images/til-logo-144x144-866373717b4dc8f05b886baaf7abae3b.png?vsn=d:1 

GET http://localhost:43751/images/til-logo-144x144-866373717b4dc8f05b886baaf7abae3b.png?vsn=d net::ERR_CONNECTION_REFUSED

Error while trying to use the following icon from the Manifest: http://localhost:43751/images/til-logo-144x144-866373717b4dc8f05b886baaf7abae3b.png?vsn=d (Download error or resource isn't a valid image)

Not sure if the config needs to be changed here: tilex/config.exs at master · hashrocket/tilex · GitHub since this is where I find localhost only existing or if it needs to be added to the Heroku config vars, but I have inputted in the SECRET_KEY_BASE on Heroku.

The dyno is using: web MIX_ENV=prod mix phx.server and made sure it’s pointing to my app.
Sorry if I’m not providing all the information needed, so please let me know if I’m missing something.

Marked As Solved

al2o3cr

al2o3cr

The error here appears to be a missing canonical_domain:

which is set in config/config.exs:

This suggests to me that HOST is not set correctly in the environment.

Also Liked

wmnnd

wmnnd

Hey there!

Just a quick note: Usually people prefer building a Release first and deploying that instead of installing Elixir and mix and then using mix phx.server. Check out the docs on Releases here:

To address your immediate issue, did you make sure to a) install and build your assets (npm run deploy --prefix ./assets) and b) compile your assets with mix phx.digest?

I also recommend you take a look at the Deployment Guide from Phoenix:
https://hexdocs.pm/phoenix/deployment.html

In case the issue is actually related to the generation of absolute URLs: You might have to change the URL configuration from

config :tilex, TilexWeb.Endpoint,
  url: [host: "localhost"],

to something like

config :tilex, TilexWeb.Endpoint,
  url: [host: "example.com", scheme: :https],

(see Phoenix.Endpoint — Phoenix v1.5.7)

axelson

axelson

Scenic Core Team

Generally I would probably write this something more like:

base = System.get_env("EDGE_URL") || System.get_env("HOST") || "https://stoiven-til.herokuapp.com"
static_url =
  URI.parse(base)
  |> Map.from_struct()

But calling Map.from_struct on a %URI{} seems highly atypical. Usually I would call to_string on the %URI{} to get out a plan URL (e.g. "https://stoiven-til.herokuapp.com"), but if you wanted that in this case you would not even need URI.parse unless you’re using it for validation. Can you show how you’re using static_url?

For the other issues I think you should post a new topic, and make sure to include the implementation of the controllers (along with the exceptions).

stoiven

stoiven

Well what did ya know…I should def be reading more :sweat_smile:. I appreciate the help! I got it up and running now!

Where Next?

Popular in Questions Top

jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement