Redirect to maintenance page based on settings on database
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
Hello everyone, so I'm currently trying to implement redirect to maintenance page based on value on my website settings inside database.
I've tried fetching the settings on
But it's always use the cache, so if I turned off
I already tried using
I also tried to use
It's working like i want, but when I tried to change page using
Is there any proper way to implement this?
I've tried fetching the settings on
layout.tsx and then redirect if the value of isMaintenance is true.But it's always use the cache, so if I turned off
isMaintenance on my database, it still return true on the page.I already tried using
cache: no-store and also next: {revalidate: 10}, but it's still the same.I also tried to use
middleware.ts, checking if the request is not contains _next it will fetch the settings from database.It's working like i want, but when I tried to change page using
Link it return error Error [SyntaxError]: Unexpected end of JSON inputIs there any proper way to implement this?
2 Replies
What are you using to fetch the data? Regular
fetch or some external package?Spectacled CaimanOP
I'm currently using regular
fetch