0

I'm using Sitecore 10.1 with JSS 16.0.0. In connected mode when I visit a Sitecore path, it gives a 404 error.

For example:-

http://localhost:3000/sitecore/api/layout/render/jss?item=%2F&sc_lang=en&sc_apikey=%3D4F3181-E8CF-49E9-9783-00605AF39941%7D

enter image description here

Based on setupProxy.js, it should be proxied:

app.use(proxy('/sitecore', { target: config.sitecoreApiHost }));

Does anybody know how I can fix this?

1 Answer 1

0

After some more research I found the following PR: https://github.com/Sitecore/jss/pull/808

It seems this was a bug and fixed in JSS 19.0.0.

If you're on an older version you should update your setupProxy.js to this:

// when in connected mode we want to proxy Sitecore paths
// off to Sitecore

app.use(proxy('/sitecore', { target: config.sitecoreApiHost, changeOrigin: true }));
// media items
app.use(proxy('/-', { target: config.sitecoreApiHost, changeOrigin: true }));
// visitor identification
app.use(proxy('/layouts', { target: config.sitecoreApiHost, changeOrigin: true }));

After this the request worked instead of a 404:

enter image description here

Your Answer

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

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