Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextJS on demand revalidation (ISR) not updating pages in Azure SWA (works locally and on Vercel) #1503

Open
18-28 opened this issue Jun 25, 2024 · 0 comments

Comments

@18-28
Copy link

18-28 commented Jun 25, 2024

Describe the bug
I have a NextJS app that uses the pages router in Azure SWA. It is literally just an npx create-next-app with one page configured to get data from a headless CMS inside getStaticProps and then display the data on the page.

I have then set up an api route in Next that uses .revalidate() to revalidate the page (code below).

Everything works fine when I create and locally host a production build using npm run build and npm run start. Everything also works when I deploy to Vercel. I change the data in the CMS > call the API route to trigger revalidation > reload page > see changes. Just not seeing the same results in Azure SWA, as the content is not updating.

Using npx create-next-app also creates an api endpoint /hello which i have tested after deploying to Azure SWA and that seems to be working fine.

I am on the free hosting plan. not sure if this makes any difference?

To Reproduce
Steps to reproduce the behavior:

  1. Create new Next app using npx create-next-app using the pages directory.
  2. Configure '/' page to get data from headless CMS.
  3. Create api route using code above.
  4. Deploy to Azure SWA.
  5. Update content in headless CMS.
  6. Call API endpoint to revalidate page.
  7. Refresh page hosted on Azure SWA - content should have updated but it hasn't.

API route that handles revalidation request:

export default async function revalidate(req, res){
    try {
        console.log('revalidating: /')
        await res.revalidate('/')
        return res.status(200).json({ message: 'Revalidated: /' })
    } catch (error) {
        return res.status(500).json({ error: error.message })
    }
}

Expected behavior
Same steps as the To Reproduce section, except the final step sees updated content. Again - this is working locally and in Vercel.

Device info (if applicable):
Not device specific. Tried across multiple machines.

Additional context
My first time creating an issue in Github. Please let me know if any more details are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant