Skip to content

Commit 455985e

Browse files
committed
review
1 parent ebeb797 commit 455985e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/open-next/src/overrides/wrappers/express-dev.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ const wrapper: WrapperHandler = async (handler, converter) => {
3434
});
3535

3636
app.all("*paths", async (req, res) => {
37+
if (req.protocol === "http" && req.hostname === "localhost") {
38+
// This is used internally by Next.js during redirects in server actions. We need to set it to the origin of the request.
39+
process.env.__NEXT_PRIVATE_ORIGIN = `${req.protocol}://${req.hostname}`;
40+
// This is to make `next-auth` and other libraries that rely on this header to work locally out of the box.
41+
req.headers["x-forwarded-proto"] = req.protocol;
42+
}
3743
const internalEvent = await converter.convertFrom(req);
3844
const streamCreator: StreamCreator = {
3945
writeHeaders: (prelude) => {

0 commit comments

Comments
 (0)