fix: authjs reads correct cookie in dev and prod
This commit is contained in:
@@ -41,12 +41,6 @@ const authjsConfig = {
|
||||
trustHost: true,
|
||||
// TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
||||
secret: "buginoo",
|
||||
/** Needed to specify cookie name because for some reason in production it
|
||||
* wasn't reading the correct cookie but in development it was. So we need to
|
||||
* make sure both development and production are using the same cookie name.*/
|
||||
cookies: {
|
||||
state: { name: "__Secure-authjs.session-token" },
|
||||
},
|
||||
providers: [
|
||||
// TODO: Choose and implement providers
|
||||
// CredentialsProvider({
|
||||
|
||||
@@ -28,7 +28,14 @@ export const trpcHandler = ((endpoint) => (request, context, runtime) => {
|
||||
const jwt = await getToken({
|
||||
req,
|
||||
secret: "buginoo",
|
||||
cookieName: "__Secure-authjs.session-token",
|
||||
/** Needed to specify cookie name because for some reason in production
|
||||
* it wasn't reading the correct cookie but in development it was. It
|
||||
* was not straightforward to fix the name of the cookie in
|
||||
* `authOptions`, so I adjusted what cookie to read from here: */
|
||||
cookieName:
|
||||
env.NODE_ENV === "production"
|
||||
? "__Secure-authjs.session-token"
|
||||
: "authjs.session-token",
|
||||
});
|
||||
return {
|
||||
...context,
|
||||
|
||||
+11
-1
@@ -5,4 +5,14 @@ compatibility_flags = [ "nodejs_compat" ]
|
||||
|
||||
[vars]
|
||||
MILVUS_ADDRESS = "in03-639fdba4bcde098.serverless.gcp-us-west1.cloud.zilliz.com"
|
||||
MILVUS_USERNAME = "db_639fdba4bcde098"
|
||||
MILVUS_USERNAME = "db_639fdba4bcde098"
|
||||
|
||||
[env.production.vars]
|
||||
MILVUS_ADDRESS = "in03-639fdba4bcde098.serverless.gcp-us-west1.cloud.zilliz.com"
|
||||
MILVUS_USERNAME = "db_639fdba4bcde098"
|
||||
NODE_ENV = "production"
|
||||
|
||||
[env.preview.vars]
|
||||
MILVUS_ADDRESS = "in03-639fdba4bcde098.serverless.gcp-us-west1.cloud.zilliz.com"
|
||||
MILVUS_USERNAME = "db_639fdba4bcde098"
|
||||
NODE_ENV = "development"
|
||||
Reference in New Issue
Block a user