Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to load resource: the server responded with a status of 404 (Not Found)

I have rails app which are working perfectly in the local computer. But when I'm deploying it on Heroku I get next error in the browser:

Failed to load resource: the server responded with a status of 404 (Not Found) http://hollow-cloud-nnn.herokuapp.com/stylesheets/application.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://hollow-cloud-nnn.herokuapp.com/javascripts/application.js

I have this files in the app\assets\javascript and \app\assets\stylesheets folder.

Here is my config\production.rb:

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

# Generate digests for assets URLs
config.assets.digest = true

Here is console output of deployment:

       Using mongoid (2.4.7)
       Using rails (3.2.1)
       Using sass (3.1.15)
       Using sass-rails (3.2.5)
       Using uglifier (1.2.3)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 15.8MB
-----> Launching... done, v24
       http://hollow-cloud-7412.herokuapp.com deployed to Heroku

To [email protected]:hollow-cloud-7412.git
   cb8ded3..dc103ac  master -> master

How can I fix it?

like image 803
ceth Avatar asked Mar 27 '12 11:03

ceth


People also ask

How do I fix failed to load resource the server responded with a status 404?

The only way to fix this is to make sure that the CSS and JS files are properly linked within the HTML. Check whether the folder, file and directory name of these files are spelt correctly. Another way to fix this is by using an absolute URL instead of a relative URL.

What does Failed to load resource the server responded with a status of 404 Not Found mean?

An invalid URL causes the failed to load resource: the server responded with a status of 404 () react error. An example, where you can have an invalid URL goes as such: You build your React project locally on your system. Use a web publishing tool like Surge to test the website.


1 Answers

You should precompile assets or set config.assets.compile = true in your production environment.

More information is available on heroku dev center, read how to use rails 3.1+ asset pipeline on heroku.

like image 92
NARKOZ Avatar answered Oct 22 '22 21:10

NARKOZ