On cloudfront, it is possible to let cloudfront itself add security headers to prevent connections to unpredicted URLS, which casuses the following error:

 

To fix this:

  1. Log on to AWS Console
  2. Navigate to Cloudfront
  3. Navigate to Distributions
  4. Open the tab Behaviors

  5. Select the existing Behaviors, and click on Edit

  6. Scroll down towards Function Associations, check if any functions exist there:
    Here you can see it is a Cloudfront Function changing your headers, and as such we will have to edit it.
  7. Navigate back to Cloudfront > Functions
  8. Open up the function found in the Distribution.
  9. Edit the Function Code as desired to add or delete
  10. Save
  11. You should now get the message that you have unpublished changes:
  12. Open up the tab and click the button Publish Function
  13. Problem should now be resolved after it has been refreshed: