This is the repository - https://github.com/RejaurRahman/portfolio-sanity
Don’t know why I am getting this issue.
@Ronny Your app link is private:
When you say:
when I run the project locally I am getting no errors
Do you mean your Development command or your Build command?
You should always confirm it works locally by running exactly the same command locally as you’re running on Netlify, since most systems do different things under the two modes and you can accidentally confuse yourself.
When I run your repository locally with npm run build I receive the following error:
The error itself points to help within the nextjs documentation:
It looks like it’s case sensitivity related though, since it says it can’t resolve
Headerlogo.module.scss while the file it’s within is
HeaderLogo.component.tsx, notice the difference in capitalization for
I am getting another error now
I don’t get it because I have had the environment variables so I don’t know why its not working.
@Ronny Check how you’re constructing these URL’s as the error occurring is:
10:12:35 AM: TypeError: Failed to parse URL from
10:12:35 AM: undefined/api/getContact
If the front portion for example is coming from the environment variables you mention, then make sure they’re set correctly in Netlify:
Hi, thank you for the reply. I added the environment variable on Netlify. I am getting this error. Not sure what might be causing this - Netlify App
@Ronny I can’t really help much with this one as I don’t really assist with Next.js based questions.
Projects built with it tend to have extra levels of complexity, automatically generated serverless functions, and use middleware, which all add up to extra potential points of failure.
That said, the root error is:
10:36:50 AM: SyntaxError: Unexpected token < in JSON at position 0
10:36:50 AM: at JSON.parse (<anonymous>)
It indicates something is running
JSON.parse and that the json is malformed.
< is usually an indication that it has accidentally been given a HTML string instead of JSON string.
When Next.js fails it tends to provide a URL you can check in their documentation for possible solutions, you can see that here in your log:
10:36:50 AM: Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Normally I might say to check your redirects to make sure you don’t have a catch all rule that’s inadvertently returning HTML for a route that’s supposed to be JSON, but with Next.js from my perspective it could be literally anything causing it.