I am using Redux Toolkit Query to occasionally refresh the jwt token:
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const refreshApi = createApi({
reducerPath: "apiSlice",
baseQuery: fetchBaseQuery({
baseUrl: `${process.env.NEXT_PUBLIC_SERVER_URL}`,
credentials: "include",
}),
endpoints: (builder) => ({
refreshAuthorization: builder.query({
query: () => "/api/auth/refresh",
}),
}),
});
export const { useRefreshAuthorizationQuery } = refreshApi;
This is the response I expect from my server:
return res
.cookie("accessToken", accessToken, {
httpOnly: true,
secure: config.get("isSecure"),
sameSite: "none",
})
However, I encountered this error: https://i.sstatic.net/bNkwB.png
It appears that the front-end is expecting JSON but I am only returning a status.