Public Folder in Heroku Not Working with Images and Routes

岁酱吖の 提交于 2020-07-10 07:07:48

问题


I am at a loss... I have tried so many different things but can not get this to work right.

Regardless if I run the Build or if Heroku runs the build, something weird is happening with the Public folder in my react app.

Everything works really well in the local server. But things are not working the right way when I launch it to Heroku -

First, I was storing my background Image for the home page in the public folder - It worked in the local server but not when I launched it to Heroku.

The Favicon also will not work in the heroku launch.

Lastly, it also wont register my routes. Locally I can go to /admin, but when launched to Heroku, it gives me a 503 error.

Not quite sure what code to include here - I am thinking maybe it has something to do with git? Not sure!

Thanks for your help!

Here is the Heroku Log ---

2020-07-03T23:26:06.755835+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/aaaa" host=www.brianpruzzo.com request_id=1d6e5d13-5464-4ca5-8965-8e70aa5fa915 fwd="77.255.15.191" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https

2020-07-03T23:26:13.767848+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/manifest.json" host=www.brianpruzzo.com request_id=f218a673-5a9a-484c-9fe9-002689f69f9f fwd="77.255.15.191" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https


回答1:


Alright! After a while I finally figured out the issue... be sure to check that the static route in your express server comes before your other routes. Better yet... use a router.... Agh! It got me.



来源:https://stackoverflow.com/questions/62723427/public-folder-in-heroku-not-working-with-images-and-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!