Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-pillows-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

fix(expres-dev): Ensure x-forwarded-proto and \_\_NEXT_PRIVATE_ORIGIN is set
6 changes: 6 additions & 0 deletions packages/open-next/src/overrides/wrappers/express-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const wrapper: WrapperHandler = async (handler, converter) => {
});

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