We are using a Statamic site built off Laravel + Forge to send JSON data to another website with the Fetch plugin.

The JSON is loading properly, and we are able to fetch the data on the external site; however, we keep receiving this CORS error:

Access to fetch at 'https://domain.com/!/Fetch/collection/courses' from origin 'http://localhost:7777' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I talked with Laravel Forge about configuring the Nginx file, but there referred me here: https://github.com/barryvdh/laravel-cors

Questions

  • Is there a way to integrate this with Statamic?
  • I have whitelisted any possible domains on the Fetch settings page. Is there any other settings I could add to remove this error on Fetch?

Thanks! Any help appreciated.