79626264

Date: 2025-05-17 06:51:48
Score: 2.5
Natty:
Report link

For those who might have the same problem, I have figured out that I can make a reverse proxy using Next.js rewrites function.

I have created a reverse proxy like this in next.config.js

async rewrites() {
    return [
      {
        source: "/api/:path*",
        destination: `${process.env.NEXT_PUBLIC_BACKEND_URL}/:path*`,
      },
    ];
  },

then changed my cookie to be like this

res.cookie("auth_session", token, {
    httpOnly: true,
    secure: true,
    sameSite: "lax",
    maxAge: 60 * 60 * 24 * 30,
    path: "/",
})
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): have the same problem
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Raffi