I'm encountering an issue with the useSWR library in my Next.js(13 /app) application. In development, everything works as expected, but in production, the data fetched by useSWR doesn't seem to update, even though I can see the API calls being made and I've set a refresh interval of 10 seconds.
Here's what I'm trying to do: I have a list of todos, and I want to add a new todo to the list. I'm using useSWR to fetch and display the list, with a refresh interval of 10 seconds to keep it up-to-date. However, the newly added todo is not appearing in the list in production.
I've also tried using the mutate function to manually trigger a revalidation, but that's not working either.
const fetcher = async (url: string) => await axios.get(url).then(res => res.data.todos)
const { data: todos, error, mutate } = useSWR<Todos[]>('/api/get-todos', fetcher)
I'm seeing the API calls being made, but the data remains unchanged. What could be causing this issue in production, and how can I ensure that the data updates as expected?
Any help or suggestions would be greatly appreciated. Thank you!