Skip to content

Commit

Permalink
🐛 fix: bypass vercel deployment protection (lobehub#3627)
Browse files Browse the repository at this point in the history
  • Loading branch information
phuctm97 authored Aug 27, 2024
1 parent f41566b commit 47da20d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/server/routers/async/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import type { AsyncRouter } from './index';

export const createAsyncServerClient = async (userId: string, payload: JWTPayload) => {
const gateKeeper = await KeyVaultsGateKeeper.initWithEnvKey();

const headers: Record<string, string> = {
Authorization: `Bearer ${serverDBEnv.KEY_VAULTS_SECRET}`,
[LOBE_CHAT_AUTH_HEADER]: await gateKeeper.encrypt(JSON.stringify({ payload, userId })),
};
if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {
headers['x-vercel-protection-bypass'] = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
}
return createTRPCClient<AsyncRouter>({
links: [
httpBatchLink({
headers: {
Authorization: `Bearer ${serverDBEnv.KEY_VAULTS_SECRET}`,
[LOBE_CHAT_AUTH_HEADER]: await gateKeeper.encrypt(JSON.stringify({ payload, userId })),
},
headers,
transformer: superjson,
url: urlJoin(appEnv.APP_URL!, '/trpc/async'),
}),
Expand Down

0 comments on commit 47da20d

Please sign in to comment.