tag inside the NextJS _document.js file. _document.js impor" /> tag inside the NextJS _document.js file. _document.js impor" /> tag inside the NextJS _document.js file. _document.js impor"/>

Snipcart with NextJS CORS issue with loading localisation file

33 Views Asked by At

Following the Snipcart localisation docs, I am adding lang="sl"attribute in my main <html> tag inside the NextJS _document.js file.

_document.js

import Document, { Html, Head, Main, NextScript } from "next/document";

export default class MyDocument extends Document {
  render() {
    return (
      <Html lang="sl">
        <Head />
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}

The langattribute is properly rendered on the site, but Snipcart does not load sl.json translations. Instead console logs the following two errors:

Access to XMLHttpRequest at 'https://cdn.snipcart.com/themes/v3.0.16/l10n/sl.json' from origin 'https://flororo.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. cdn.snipcart.com/themes/v3.0.16/l10n/sl.json:1

Failed to load resource: net::ERR_FAILED

What am I doing wrong?

0

There are 0 best solutions below