passthrough authorization header to trpc/get-tarif
This commit is contained in:
parent
16b7188773
commit
c18875f369
@ -83,7 +83,7 @@ export function createLink(headers) {
|
||||
return {
|
||||
headers: {
|
||||
...existingHeaders,
|
||||
authorization: headers.authorization,
|
||||
authorization: headers?.authorization,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user