Closed softshipper closed 3 years ago
Have you checked whether session.idToken
is defined when you enter the fetchOptions
? I just did a test with headers: { test: 'x' }
which seemed to work fine
Repro: https://codesandbox.io/s/nice-curran-vjrd1?file=/pages/index.js
@JoviDeCroock I have changed to
const client = initUrqlClient({
url: addr.gql,
exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange],
fetchOptions: () => {
return {headers: { test: 'x' }}
}
}, false);
and unfortunately, the headers
are without test
{
host: 'localhost:3000',
connection: 'keep-alive',
'content-length': '96',
pragma: 'no-cache',
'cache-control': 'no-cache',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
'content-type': 'application/json',
accept: '*/*',
'sec-gpc': '1',
origin: 'http://localhost:3000',
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
referer: 'http://localhost:3000/account',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
cookie: 'appSession=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaWF0IjoxNjIwMDY5NTkxLCJ1YXQiOjE2MjAwNzUyMDMsImV4cCI6MTYyMDE2MTYwM30..904-aZyhrY7jhJGl.LdIxJH-ZVyOfPi4ExSuazmL3rSTdn0C1Jy-17psPwA7-bS2txliy4JJXZo-NJcYeBaxNlUWBB3FXPv-zYPJk-mG4-dXtk8IFSVhIPGFCCchmFW2-X0pCCHhTEcDm_Axao7MiCahBeNFhbsaEw_3s8OwQ9ojwdNNBtg0bZBtuBCbC_WB-4-fX9haXyYIidoFiis2-Kh969gkQM8LfKzRIcolTbuJsuroRMgUsxUtcdhNA2jJRUrBSTMVCEw80NBvrq_UjgszDVmlHGVIUQcIpRS11RJzvUYMvw-yng5sfqpgnyDxfbLhjo4OL1f0fPMTqT4IRhrr34oCAYvE3bU-5RXLyJCswo2wqjTAIJCm0NxnG9l8GBeql2uVxd389K2S2jYp8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pKjXgDa0OmvVdqO_UJWMj4CO04uoqIOaHsNTDOAzPu02tAczdpOVgTZ-qx1wJtWAnRB4CLah_LPEK7goh8ylz7FzSlgudZTPsqYw_UhDVaWb3kw9f132hs-c8SSvcORmQr2J1pnAaiP-pJusw7RNUeVDMB7hWxLpcan9EPWDZ6iq0FCbrNhzL6nWvbH2TIaSp7_RlN7uXr0EOWWQYRg4Tjjd3fXCDde2qkjHUi8JEHEjiXr_PMQca9sOSw2OG8aaqH_BfI8qHuMsAqWFWLfr8JpBKYtclIXiiHR-ZchwqqTcwRSkXGv4rKhsgkPblRFScP7WTBMlbdwUwFs3jcAxcPE38mgjl3X1dJoUXOBu26ke1yvZxK9Kdzy_Ahdpn6AA.hgCEdvwat_CWGZC4DB9x0Q'
}
I have changed the ApolloServer handler to
const server = new ApolloServer({
schema,
context: () => new Context()
});
const handler = server.createHandler({path: "/api/graphql"});
export const config = {
api: {
bodyParser: false,
},
};
export default function api(req: NextApiRequest, res: NextApiResponse<void>) {
console.log(req.headers)
return handler(req, res);
}
and the header test
appears now:
app-ui: {
app-ui: 'content-type': 'application/json',
app-ui: test: 'x',
app-ui: accept: '*/*',
app-ui: 'content-length': '96',
app-ui: 'user-agent': 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)',
app-ui: 'accept-encoding': 'gzip,deflate',
app-ui: connection: 'close',
app-ui: host: 'localhost:3000'
app-ui: }
Something is wrong with the withApiAuthRequired
method.
Thanks a lot
Hi all
I am using NextJS and I followed the tutorials on https://formidable.com/open-source/urql/docs/advanced/server-side-rendering/#nextjs to set up
URQL
client for NextJS.I have created the client as follows:
as the query result I have got:
the GraphQL server is set up as follows:
the
req.headers
does not contain the Authorization header.Best regards Softshipper