Skip to content

Commit

Permalink
Trying to fix the heroku production bug
Browse files Browse the repository at this point in the history
  • Loading branch information
developeratul committed Sep 14, 2021
1 parent 51b926e commit aecacfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
15 changes: 4 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ app.use("/comment", commentRouter_1.default);
app.use("/get_settings", settingsRouter_1.default);
// for production
if (process.env.NODE_ENV === "production") {
app.use((req, res, next) => {
if (req.header("x-forwarded-proto") !== "https")
res.redirect(`https://${req.header("host")}${req.url}`);
else
next();
});
}
if (process.env.NODE_ENV === "production") {
app.use(express_1.default.static("client/build"));
app.get("*", (req, res) => {
res.sendFile(path_1.default.resolve(__dirname, "client", "build", "index.html"));
app.use(express_1.default.static('client/build'));
app.get('*', function (req, res) {
const fullPath = path_1.default.join(__dirname, '../client', 'build', 'index.html');
res.sendFile(fullPath);
});
}
// error handlings
Expand Down
19 changes: 6 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,12 @@ app.use("/get_settings", settingsRouter);

// for production
if (process.env.NODE_ENV === "production") {
app.use((req, res, next) => {
if (req.header("x-forwarded-proto") !== "https")
res.redirect(`https://${req.header("host")}${req.url}`);
else next();
});
}

if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));

app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
app.use(express.static('client/build'))

app.get('*', function (req, res) {
const fullPath = path.join(__dirname, '../client', 'build', 'index.html')
res.sendFile(fullPath)
})
}

// error handlings
Expand Down

0 comments on commit aecacfb

Please sign in to comment.