I'm having issue with getServerSideProps with axios interceptor. Its return response 401 which is unauthorised request. But when in client side in useEffect, it can be fetch the response from the server which is authorized.
so basically my axios interceptor is something like this
api.interceptors.request.use(async (request) => {
if (!request.headers.Authorization) { request.headers.Authorization =Bearer ${token}; } }
then i use
api.get(API_ROUTE).then(({data}) => data)
inside page functional component
import { getCreateCourseSchema } from 'api/API';
export const Component = () => { ... }
export async function getServerSideProps(context) {
const createSchema = await getCreateCourseSchema();
return {
props: {
createSchema,
},
};
}
Why the SSR does not able to define or identify my axios interceptor even though I have set it?