0π
I assume that You have installed Heroku CLI, logged in and connected to Your github account.
If so this is how Iβve deployed my project.
β¦
I have created a new branch i.e. deployBranch
Then in the frontend folder I have run βnpm run buildβ.
I have copied the βdistβ folder to project folder.
In backend file (server.js or in your case app.js) I have added this code just after the routes:
const trajectory = path.resolve();
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(trajectory, "/dist")));
app.get("*", (req, res) =>
res.sendFile(path.resolve(trajectory, "dist", "index.html"))
);
}
(donβt add heroku-postbuild script to package.json and delete /dist from .gitignore file in master project folder if there is one)
After this I commited all the changes to a new branch.
git push βset-upstream origin deployBranch
Then in heroku, i have created the new project.
In deploy section βApp connected to GitHubβ I have connected it to my project github repo.
Iβve changed the branch to deployBranch in βManual deployβ and choose βdeploy branchβ
After that all that was left to do was to add config vars in the settings from .env