Heroku中的公用文件夹不适用于图像和路线 [英] Public Folder in Heroku Not Working with Images and Routes

查看:91
本文介绍了Heroku中的公用文件夹不适用于图像和路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很茫然...我尝试了很多不同的事情,但是无法正常工作.

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

无论我运行构建还是Heroku运行构建,react应用中的Public文件夹都发生了奇怪的事情.

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

一切在本地服务器上都运行良好.但是,当我将其启动到Heroku时,事情并没有以正确的方式运行-

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

首先,我将主页的背景图像存储在公用文件夹中-它在本地服务器上有效,但当我将其启动到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.

Favicon也无法在heroku发射中使用.

The Favicon also will not work in the heroku launch.

最后,它也不会注册我的路线.我可以在本地访问/admin,但是启动到Heroku时会出现503错误.

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

不太确定要在此处包含什么代码-我在想这可能与git有关吗?不确定!

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

感谢您的帮助!

这是Heroku日志---

Here is the Heroku Log ---

2020-07-03T23:26:06.755835 + 00:00 heroku [router]:at =错误代码= H12 desc =请求超时" 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服务= 30000ms status = 503字节= 0协议= https

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 =错误代码= H12 desc =请求超时"方法=获取路径="/manifest.json" host = www.brianpruzzo.com request_id = f218a673-5a9a-484c-9fe9-002689f69f9f fwd ="77.255.15.191" dyno = web.1 connect = 1ms服务= 30000ms status = 503字节= 0协议= 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

推荐答案

好的!过了一会儿,我终于弄清楚了这个问题...一定要检查一下快递服务器中的静态路由是否在其他路由之前.更好的...使用路由器......啊!它得到了我.

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.

这篇关于Heroku中的公用文件夹不适用于图像和路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆