Background of the problemPlanning to deploy my website built with React to production mode with npm run build command!ProblemFirst time trying to deploy my app to production with npm run build! but!__dirname in backend\index.ts is referring to the build folder inside of the backend folder instead of the build folder outside of src.Here's what the console.log(__dirname) looks likeprojects\spotify\src\backend\build should be: projects\spotify\build This is what my folders structure look likeHere's my backend/index.ts:...... ...... const PORT = process.env.PORT || 5000; //PROBLEM: console.log(__dirname); //projects\spotify\src\backend\build //should be: \\projects\spotify\build app.use(express.static(path.join(__dirname, "../../build"))); app.get("*", function (req, res) { res.sendFile(path.join(__dirname, "../../build")); }); app.listen(PORT); How should this be fixed?
Submitted September 22, 2020 at 04:29PM by badboyzpwns
No comments:
Post a Comment