Previewing uploaded files cors problem

I’m using Rocketchat in development environment and accessing local Rocketchat server from private ip in the browser.
As domains differ I’m facing cors issues.
I have enabled cors for Rest api.
Rest api is working fine but I don’t know how to add cors headers for uploaded files as it needs auth and I’m requesting with ajax(from another domain) to preview the image.


File url: 192.xxx.xxx.xxx/file-upload/m5Z5PTTB9QJQPbzMz/Picture2.png
Error: CORS header ‘Access-Control-Allow-Origin’ missing

Thanks in advance

I think you probably need to do some general reading on CORS so you understand the issue here.

https://www.google.com/search?q=cors+header+‘access-control-allow-origin’+missing&oq=CORS+header+‘Access-Control-Allow-Origin’+missing&aqs=chrome.0.0l10.898j0j7&sourceid=chrome&ie=UTF-8

Thanks for replying. I know the problem but I don’t know how to fix it.
I successfully added Access-Control-Allow-Origin header for Rest Api (By enabling it in the setting)
but there is no such option for files.

Ahh - knowing what a problem is means you do know how to fix it.

You have an error, which you don’t know how to fix. Slightly different issue :wink:

Can you describe in a bit more detail exactly what you are doing and how you get the error.

So show us a bit more clearly what you are trying to do - the actual API calls, and the errors as displayed.

I’m communicating with rest api in a web page.
I’m basically trying to show an image from the chat in the browser.
I can’t simply use img tag because the browser sends a GET request without tokens.
So I tried to send XHR request to fetch the image from the Rocketchat server.
Request:

Error: