Currently, I am utilizing Next.js along with next-redux-wrapper
and RTK Query. My application is performing external API requests on the server side. The implementation of the request looks like this:
CompaniesPage.getInitialProps = initialPagePropsWithCompanies;
// ---
import { createWrapper } from 'next-redux-wrapper';
const wrapper = createWrapper<ReturnType<typeof makeStore>>(makeStore);
export const initialPagePropsWithCompanies = wrapper.getInitialPageProps((store: AppStore) => async () => {
store.dispatch(api.endpoints.getHomePage.initiate());
await Promise.all(store.dispatch(api.util.getRunningQueriesThunk()));
return { props: {} };
});
The issue at hand is that the response seems to be cached somewhere in Next.js. I'm unsure how to disable it or shorten its lifespan.
- I have the line
export const revalidate = 5;
on my page. - I've also included
cache: 'no-store'
in thefetchBaseQuery
configuration:
baseQuery: fetchBaseQuery({
baseUrl: `${process.env.NEXT_PUBLIC_PROTOCOL || 'https://'}${process.env.NEXT_PUBLIC_VERCEL_URL}/api`,
headers: {
'x-telegram-query': typeof window !== 'undefined' ? window.Telegram.WebApp.initData : '',
},
cache: 'no-store',
}),
- Additionally, I attempted adding
next: { revalidate: 5 }
to thefetchBaseQuery
configuration.
Unfortunately, none of these solutions seem to be working. I'm out of ideas. Does anyone have any suggestions?