passthrough authorization header to trpc/get-tarif

This commit is contained in:
vchikalkin 2024-05-21 18:57:06 +03:00
parent 16b7188773
commit c18875f369
3 changed files with 5 additions and 4 deletions

View File

@ -83,7 +83,7 @@ export function createLink(headers) {
return {
headers: {
...existingHeaders,
authorization: headers.authorization,
authorization: headers?.authorization,
},
};
}

View File

@ -4,7 +4,7 @@ import type { inferAsyncReturnType } from '@trpc/server';
import type { CreateNextContextOptions } from '@trpc/server/adapters/next';
export async function createContext({ req }: CreateNextContextOptions) {
const { cookie = '' } = req.headers;
const { cookie = '', authorization } = req.headers;
const user = await getUser({
headers: {
@ -16,6 +16,7 @@ export async function createContext({ req }: CreateNextContextOptions) {
scope.setUser(user);
return {
headers: { authorization },
user,
};
}

View File

@ -6,9 +6,9 @@ import configuratorHelper from '@/process/configurator/lib/helper';
import { createTRPCError } from '@/utils/trpc';
export const tarifRouter = router({
getTarif: protectedProcedure.input(GetTarifInputSchema).query(async ({ input }) => {
getTarif: protectedProcedure.input(GetTarifInputSchema).query(async ({ input, ctx }) => {
try {
const apolloClient = initializeApollo();
const apolloClient = initializeApollo(null, ctx.headers);
const { getTarifs } = configuratorHelper({ apolloClient });
return getTarifs(input);