I am getting the following error when linking posts (products) to each other in my “related products” section.
SerializableError: Error serializing
.data.relatedProducts.fields.relatedProducts.fields returned from
getServerSideProps in “/products/[slug]”.
Reason: Circular references cannot be expressed in JSON (references:
I have tried both “contentful”: “^7.14.0” and "“contentful”: “^7.1.0-beta1”.
The only solution I’ve come up with so far is to implement https://www.npmjs.com/package/safe-json-stringify to convert the data to string and then JSON.parse the stringified data.
This appears to be an issue with NextJS.
Can anyone suggest a more performant workaround other than stringifying, then reparsing?
I am bumping this for mods/devs to see.
There should be documentation on how to fetch a rich text body which contains links to entries, which contains links to entries, without everything breaking because of circular reference.