Discussions

Ask a Question
Back to All

Help with No 'Access-Control-Allow-Origin' header is present on the requested resource

(edited)

Hi,

I was wondering if someone could point me in the right direction.

When fetching an image via the API "https://api.servicem8.com/api_1.0/attachment/image_uuid.file" I am getting this response.

Access to fetch at 'service-m8-image-url' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

When clicking the "service-m8-image-url" in the error it takes me to the image but I would like to download the image.

I have a python script that has the same functionality and is working but I can't get it to work in javascript.

I have tried to set "mode: no-cors" but a login window pops up instead of using the creds sent in the header.

I am only facing this issue when requesting an image using the .file extension. All other endpoints work as expected.

Thank you for any help in advance.

Ashley