Heroku(Cedar) + Node + Express + Jade Client-side javascript files in subdirectory work locally with foreman+curl but not when pushed to Heroku

前端 未结 1 1276
失恋的感觉
失恋的感觉 2021-02-20 03:35

I am very new to node and heroku and I suspect this is some kind of simple permission issue etc, but I can\'t seem to track it down.

I have several pure javascript files

1条回答
  •  醉话见心
    2021-02-20 04:28

    I recommend you to use process.cwd() value to get specific directory

    process.env.PWD = process.cwd()
    

    at the very beginning of your web.js

    let you access files easily.

    You can do

    app.use('/heatcanvas',express.static(process.env.PWD+'/heatcanvas'));
    

    instead of using

    __dirname
    

    Warning: Make sure to execute web.js at the root directory of web.js (Heroku web.js are executed that way)

    0 讨论(0)
提交回复
热议问题