0

When trying to fetch image data inside a custom ImageProvider from an URL, I get an error: ClientException: XMLHttpRequest error., uri=https://<host>/api/v1/images/<imageId>/thumbnail-squared

The host however has CORS enabled and returns a header "access-control-allow-origin" -> "*".

The URL redirects a 302 to a signed google cloud storage file however. Might this be the issue?

Nicolas Degen
  • 1,522
  • 2
  • 15
  • 24

1 Answers1

0

Here's your solution.

It is a server-side issue. Your server is not allowing or accepting your cross-origin request. But no worries, it's 10 mins' work. All you need to do is configure your server. Doing that will allow or accept your request.

Steps:

#1. Open the Server's CPanel & then open CPanel File Manager.

#2. Look for the "public_html" directory.

#3. Look for the ".htaccess" file (Make sure you enable the view for hidden files.), Still, if you don't find the ".htaccess" file, create the ".htaccess" file.

#4. Paste the below-mentioned code in the ".htaccess" file:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"

#5. Save the ".htaccess" file.

Important: If you have the SSL certificate, consider using the "https://" prefix. If you don't have the SSL certificate, consider using the "http://" prefix.

Reference link: https://gist.github.com/nixta/0b98d7975562bc31c4c9

Dharam Budh
  • 515
  • 2
  • 9