Closed samos123 closed 2 years ago
The workaround is to add a temporary value for the cookie during build but unsure if that might have unintended security consequences. This is the additional step I added in the build phase of the docker image:
ENV COOKIE_SECRET_CURRENT=willbereplacedlater
I'm afraid that somehow this secret might persist somewhere in the docker image?
For context the reason this works for me is due to initAuth.js looking like this:
cookies: {
keys: [process.env.COOKIE_SECRET_CURRENT, process.env.COOKIE_SECRET_PREVIOUS],
httpOnly: true,
maxAge: 12 * 60 * 60 * 24 * 1000, // twelve days
overwrite: true,
path: '/',
sameSite: 'strict',
signed: true,
},
@samos123 Had this same problem. I got around it by copying my env into the working dir (I am using the example where the build happens in app and is run from root)
COPY --from=builder /app/.env* ./
I think yours would be closer to this:
COPY --from=builder ../build/.env* ./
(run this command AFTER)
WORKDIR /app
This workaround is not working for me. Am not sure if there is any issue with my code. Also is there any other workaround?
COPY . .
COPY --from=deps /app/node_modules ./node_modules
ENV NODE_ENV production
ENV COOKIES_SECRET_CURRENT $GITHUB_SHA
ENV COOKIES_SECRET_PREVIOUS $GITHUB_SHA
RUN npm run build
keys: [process.env.COOKIE_SECRET_CURRENT,process.env.COOKIE_SECRET_PREVIOUS],
httpOnly: true,
maxAge: 12 * 60 * 60 * 24 * 1000, // twelve days
overwrite: true,
path: '/',
sameSite: 'strict',
secure: process.env.NODE_ENV === 'production', // set this to false in local (non-HTTPS) development
signed: true,
Closed in #546.
Describe the bug I do a
yarn install
as part of my Dockerfile image building steps and cookies.keys seem to be required.Error observed:
Versions
next-firebase-auth
version: Firebase JS SDK: 8 Next.js: 0.14.3-alpha.0Expected behavior
yarn install
to not require cookies.keysFull Dockerfile: