Skip to content

Unexpected token '<', "<!DOCTYPE "... is not valid JSON #65663

Discussion options

You must be logged in to vote

Hi,

I see that this component, https://github.com/Eng1Mahmoud/e-commerce-next-app/blob/master/src/components/Home/categories-section/CategoriesSection.tsx, is trying to pull data from ${process.env.NEXT_PUBLIC_API_URL}/products/${categorie}/${1}/${10}, which I assume is your own server? Namely this endpoint.

That's already cause for issues. Locally it works because of a quirk with fetch cache. You can read more about this issue here: #55702

To convince yourself, remove .next first, and then build. You should see the issue on your machine as well.

Now the root problem is that you are trying to fetch data from your own server, during Server Rendering. That's not correct, and it causes broke…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Eng1Mahmoud
Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

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