Is there a way to dynamically activate or deactivate the getServerSideProps
function using an environment variable? I attempted the following approach:
if (process.env.NEXT_PUBLIC_ONOFF === 'true') {
export const getServerSideProps: GetStaticProps = async context => {
const { locale = 'en' } = context;
return {
props: {
...(await serverSideTranslations(locale, [
'common',
]))
}
};
};
}
Unfortunately, I encountered a TypeScript error stating
Modifiers cannot appear here.ts(1184)
.
How can I effectively enable or disable serversideprops based on the value of my environment variable?