Watch a live product demo 👀 See how Sanity powers richer commerce experiences

Next.js Deployed on Vercel Now - Dynamic Links Return 'An Unexpected Error has Occurred'

12 replies
Last updated: May 9, 2020
Hello. I followed the Next.js tutorial, deployed on Now, the dynamic links renders
An unexpected error has occurred.
May 9, 2020, 8:39 AM
Here’s what I did: Cloned the repo for the tutorial: https://github.com/sanity-io/tutorial-sanity-blog-react-next
May 9, 2020, 8:40 AM
Followed the steps in the readme file. Including deployment to Now.
May 9, 2020, 8:40 AM
Currently deployed to: https://testbug.now.sh
May 9, 2020, 8:41 AM
I’ve not changed any of the code in the repo, other than following the instructions in the readme. I added some comments to the index page.
May 9, 2020, 8:41 AM
I tried including a hardcoded link to the page the dynamic link points to – that works.
May 9, 2020, 8:42 AM
Like I said, the blog article page shows
An unexpected error has occurred.
Refreshing the page renders the page fine.
May 9, 2020, 8:43 AM
Have you added https://testbug.now.sh to the CORS settings in manage.sanity.io ?
May 9, 2020, 8:43 AM
Let’s see. I ran:
sanity cors add <http://localhost:3000> --no-credentials
May 9, 2020, 8:43 AM
But of course I need to add the remote site too…
May 9, 2020, 8:44 AM
Yeah, try that. I think that will fix it
May 9, 2020, 8:44 AM
It does. Thanks very much!
May 9, 2020, 8:45 AM
Coolio!
May 9, 2020, 8:46 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing