I’m developing an app that generates images via a ...
# ktor
y
I’m developing an app that generates images via a REST API. I am using ktor client. The process involves: 1-Sending a POST request with JSON payload (prompt, parameters). 2-Receiving a byte array response (image data). 3- Converting the byte array to a Base64 data URL for display. everything works in Android, iOS, Desktop but When running the WASM build, the app throws a CORS error during the POST request to the image generation API:
Access to fetch at '<https://chutes-chroma.chutes.ai/generate>' from origin '' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status
. how could I fix this issue?
j
Hi, I'm interested in the problem you are facing now, could you please post more details about the request.
🙏 1
a
From https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS:
For security reasons, browsers restrict cross-origin HTTP requests initiated from scripts. For example,
fetch()
and
XMLHttpRequest
follow the same-origin policy. This means that a web application using those APIs can only request resources from the same origin the application was loaded from unless the response from other origins includes the right CORS headers.
To solve the problem, you can configure the server to allow requests from your origin or use a proxy server.
1
y
Thank you guys for the help.