RandomAPI / Randomuser.me-Node

Source code that powers randomuser.me
https://randomuser.me
MIT License
1.34k stars 268 forks source link

`Access-Control-Allow-Origin` mission on image requests #192

Open morwoen opened 3 years ago

morwoen commented 3 years ago

When an image is requested through an API call rather than through an image tag on the page the browser blocks the request due to missing Access-Control-Allow-Origin. I am using the API in a Unity game embedding the WebGL player in a website.

I would gladly contribute to the API but failed to find where the current header is set to move it to apply to images as well 😅

MattyDub commented 2 years ago

I'm also seeing this issue. Was it ever addressed?

I'm trying to load an image like:

<img class="user-image" alt="User portrait" crossorigin="" src="https://randomuser.me/api/portraits/thumb/women/65.jpg" referrerpolicy="no-referrer">

...and my browser dev tools return a "CORS missing allow origin" message.

Souvlaki42 commented 2 years ago

I had a similar problem with Access-Control-Allow-Origin. I solved it by adding the mode: "cors" and credentials: "omit" options to the request method. Can you try that please?

MattyDub commented 1 year ago

I was also able to get it to work. I was just using elements, and the fix for me was to remove the cors-related attributes.