Subdirectories not being served with express.static in heroku

社会主义新天地 提交于 2019-12-03 20:21:19

Make sure that the sub directories of your directory are added to your Git repository.

You can use heroku run 'ls ~' to help debug the issue (by observing the files on the dyno).

Putting the absolute path did not fix it for me. Your .gitignore may be excluding it.

Try changing your static dir to :

app.use(express.static(path.join(__dirname, '/../app'), { maxAge: 86400000 }));

or

app.use(express.static(path.normalize(path.join(__dirname, '../app')), { maxAge: 86400000 }));

add {{__dirname}}

<link href="{{__dirname}}/stylesheets/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>

in your layout.hbs or layout.jde

I've just had the same issue, and I've read all the different answers, some of which may have been important, but, in the end, this is the change I made after which the static content started getting served.

CALENDARSPATH = path.join(process.env.PWD, 'calendars');

...

-app.use(express.static(CALENDARSPATH, { maxAge: 86400000 }));
+app.use('/calendars', express.static(CALENDARSPATH, { maxAge: 86400000 }));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!