Changing how we determine when the application is in production mode
I use next build and next start in my ci/cd for e2e testings, which is being detected as running in production here: https://github.com/stack-auth/stack/blob/dev/packages/stack/src/lib/cookie.ts#L45
This will cause my tests to fail because of that validation (since it runs in http://localhost:3000).
Can we add an environment variable to bypass that (Or discuss some other posible solution)?
In my case I'm using gitlab ci, so const isProd = process.env.NODE_ENV === "production" && !process.env.CI should work.
FYI, I did try to force my NODE_ENV to test, but I couldn't make it work.
One problem with the approach that you mentioned is that if you're building in CI, and then publishing the build results (eg. with npm publish or exporting as a standalone Next.js server), the build will be in development mode.
In our own CI, we copy-paste the .env.development to .env.production.local before building: https://github.com/stack-auth/stack/blob/fb31827dc35bef883a8965d933e71f49b93f1f48/.github/workflows/lint-and-build.yaml#L37-L38
Another option is to set NODE_ENV=development when running the next build command, but be aware that this will create a development build (which may or may not be what you want).
Closing this issue since now we can use the env variable NEXT_PUBLIC_ALLOW_INSECURE_COOKIES to disable secure cookies (https://github.com/stack-auth/stack/commit/bd9f2f7daf36cbd489ab9e66c37f6ee8d60c507c)