From 0f15519b7e0a4e3b90bc7341730806d9a867477d Mon Sep 17 00:00:00 2001 From: simonkernel Date: Sun, 11 Sep 2022 17:52:44 -0700 Subject: [PATCH] bug fix: choose prod cookie in task and query service. --- packages/query/src/routes/rpc.js | 5 ++++- packages/task/src/routes/rpc.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/query/src/routes/rpc.js b/packages/query/src/routes/rpc.js index cb92453..152e3da 100644 --- a/packages/query/src/routes/rpc.js +++ b/packages/query/src/routes/rpc.js @@ -29,6 +29,9 @@ const SERVICE_POLICY = { } } +const PROD = process.env.ENV === 'PROD' +const COOKIE_JWT = PROD ? 'prodJWT' : 'stagingJWT' + const register = async (server, rpcPath, { seed, authMemberId, rpcEndpoint, projectId }) => { const queryService = await queryBuilder.build({ seed, authMemberId, rpcEndpoint }) @@ -40,7 +43,7 @@ const register = async (server, rpcPath, { seed, authMemberId, rpcEndpoint, proj const getJWT = (request) => { // Try to get JWT from headers or cookie const header = request.raw.headers.authorization - const cookie = request.cookies.stagingJWT + const cookie = request.cookies[COOKIE_JWT] if (!header && !cookie) { return } diff --git a/packages/task/src/routes/rpc.js b/packages/task/src/routes/rpc.js index 6da403c..892110a 100644 --- a/packages/task/src/routes/rpc.js +++ b/packages/task/src/routes/rpc.js @@ -44,6 +44,9 @@ const SERVICE_POLICY = { } } +const PROD = process.env.ENV === 'PROD' +const COOKIE_JWT = PROD ? 'prodJWT' : 'stagingJWT' + const register = async (server, rpcPath, tasksPath, { seed, serviceAccount, faucetAmount, infuraId, authMemberId, rpcEndpoint, projectId }) => { const taskService = await taskBuilder.build({ projectId, relativeUri: tasksPath }) @@ -56,7 +59,7 @@ const register = async (server, rpcPath, tasksPath, { seed, serviceAccount, fauc const getJWT = (request) => { // Try to get JWT from headers or cookie const header = request.raw.headers.authorization - const cookie = request.cookies.stagingJWT + const cookie = request.cookies[COOKIE_JWT] if (!header && !cookie) { return }