2

I'm trying to implement Sitecore Forms with the NextJS app using this official document https://doc.sitecore.com/xp/en/developers/hd/211/sitecore-headless-development/implement-a-sitecore-form-in-a-jss-next-js-app.html

Since I'm using next js I'm passing sitecoreApiHost={''} as mentioned in the document.

enter image description here

I have also followed this document to create Sitecore Form, created rendering, and added the same on the sample page; https://doc.sitecore.com/xp/en/developers/hd/211/sitecore-headless-development/walkthrough--using-a-sitecore-form-in-jss-applications.html

To simplify I have just added a redirect to the page as an action on Submit button with a couple of input boxes.

enter image description here

When the new rendering is added to the page for forms and after publishing I'm getting the following error;

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

enter image description here

Appreciate any help on this topic, thank you.

5
  • Can you check Console what are the other errors logged? May 30 at 2:56
  • Just 404 not found and 'Form submit error SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON' May 30 at 3:52
  • I assume that you are seeing that error because Forms is trying to parse the 404 HTML document as a JSON (since it expects a JSON, not a 404 html response). What happens if you instead use “Save Data” as a submit action?
    – Lala
    Jun 3 at 0:54
  • Even 'Save Data' gives the same result. Jun 6 at 0:14
  • I followed the same, added the serverSideRenderingEngineEditOnly="false" sitecore.javascriptservices.app.config and in one more config. and also added the patch of HeadlessSiteAccess processor after TransferRoutedRequest. I am still getting the same error "Unexpected token '<', "<!DOCTYPE "... is not valid JSON" in form submit. Console Error: ![enter image description here](i.stack.imgur.com/4MWbg.png) Please share any advice on it.
    – Prem Murmu
    Jun 28 at 12:58

1 Answer 1

2

Finally, I found the solution which is mentioned here;

https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB1002853

Basically, for the newly created app, one more config needs to be added which is serverSideRenderingEngineEditOnly="false" and done.

Check the showconfig.aspx for the above key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.