contentful / contentful.js

JavaScript library for Contentful's Delivery API (node & browser)
https://contentful.github.io/contentful.js
MIT License
1.18k stars 197 forks source link

Contentful throws error on iPhone 6 iOS 12.5.7 when using Next.js Pages router #2131

Open reekrd opened 8 months ago

reekrd commented 8 months ago

Contentful throws SyntaxError: Unexpected token ';'. Expected an opening '(' before a method's parameter list. on iPhone 6 iOS 12.5.7 when used in the Pages router in Next.js

However the error does not occur when using the App router (as it runs in a server component).

Version 9.3.5 of the contentful client works as expected.

Steps to Reproduce

Here is a minimal repo: https://github.com/reekrd/contentful-test

wadehammes commented 7 months ago

Similar to https://github.com/contentful/contentful.js/issues/1901

I fixed this for us by not having any client-side calls to Contentful, and doing everything in getStaticProps and passing down the response via props. If you have deeply nested references, you will want to make sure you use the includes prop on the api call setup and setting it to something high, like 10, so that all your entries get resolved.

reekrd commented 7 months ago

@wadehammes thanks for the tip. although that means a complete refactor of our current code base, so still hoping that the contentful team are able to solve this.