Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 not found static files after npm run build #1171

Closed
johhansantana opened this issue Dec 6, 2016 · 10 comments
Closed

404 not found static files after npm run build #1171

johhansantana opened this issue Dec 6, 2016 · 10 comments

Comments

@johhansantana
Copy link

I've run the following commands:

create-react-app myApp

cd myApp

npm run build

copy build folder into server

screen shot 2016-12-05 at 8 51 52 pm

What to do?

@Timer
Copy link
Contributor

Timer commented Dec 6, 2016

This seems to be more of a configuration issue with your application rather than CRA itself.
On that note, you need to make sure your web server is serving static files from the proper directory (express makes this easy, though we don't assume your backend).

If you would like to develop, you should be using the npm start command instead.

Cheers!

@Timer Timer closed this as completed Dec 6, 2016
@gaearon
Copy link
Contributor

gaearon commented Dec 6, 2016

You might also find deployment instructions helpful: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment

But yes, if you just mean to start developing you need npm start instead.

@gaearon
Copy link
Contributor

gaearon commented Dec 6, 2016

Also when you run npm run build you should see exact instructions for serving those files on the terminal screen. Have you had a chance to try following them yet? Did you have any issues doing so?

@johhansantana
Copy link
Author

johhansantana commented Dec 6, 2016

I've tried running the build via XAMPP locally, I copied the build folder into the htdocs and then started the server then went into localhost/build when I go to localhost/build/static/js/main....js it shows the file.

Do I need a node/express server to be able to run the app?

and yes I've run npm start to develop and it works nicely.

@Timer
Copy link
Contributor

Timer commented Dec 6, 2016

@JSantana90 copy the contents of the build directory into htdocs instead of the directory itself; you need to do this until #1094 is resolved.

e.g. instead of htdocs\build\index.html and htdocs\build\static\js\main*.js you want htdocs\index.html and htdocs\static\js\main*.js.

@johhansantana
Copy link
Author

@Timer that worked, thank you!

@Timer
Copy link
Contributor

Timer commented Dec 6, 2016

No problem, @JSantana90. Let us know if you're having any other issues. 😄

@pretentiousgit
Copy link

pretentiousgit commented Sep 10, 2017

Is there a way to override the need to specify the URL for the package to have CRA serve on a sub-route? Everything's being developed on a semi-random localhost port, which I would prefer not to encode into the package.json...

@Timer
Copy link
Contributor

Timer commented Sep 10, 2017

@pretentiousgit we actually ignore the specific url and only use the sub-route; so the arbitrary port is fine for homepage.

@guleus
Copy link

guleus commented Jul 4, 2018

Hello,
I'm trying to deploy and create react app. I build it and then I served it on my local machine and everthing works fine.

Now I tried to pass the contenent of the build folder to a webserver (192.168.0.91) which resides on a PLC (SAIA PLC) in my local network

If I point to http://192.168.0.91/index.html
i get the following error :
http://192.168.0.91/static/css/main.c90e76c6.css 400 (Bad Request)
If in my browser I point directly to http://192.168.0.91/static/css/main.c90e76c6.css
the answer is: "Your request has bad syntax."
For testing purposes i created a copy of that file and renamed it "main.c90.css"
If I point to that file now in the browser "http://192.168.0.91/static/css/main.c90.css"
the file gets downloaded as expected.
So in my humble opinion the problem seems to reside in web server itself, like some issues with lenghts of filenames or something like this, but I just don't know enough about servers ecc. I would really need to know if I can deploy my react projects on that kind of PLC Web server or not.
Please if somebody can help me with that I would be very grateful

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants