CORS Error trying to reach SwarmUI API
Unanswered
Munchkin posted this in #help-forum
MunchkinOP
Hi,
as mentioned above I am trying to make a fetch call to my SwarmUI.
However i keep getting hit with the cors error:
My code looks like this:
It does seem to reach the API but seems to send an error back:
my next.config.mjs
as mentioned above I am trying to make a fetch call to my SwarmUI.
However i keep getting hit with the cors error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:7821/API/GetNewSession. (Reason: CORS request did not succeed). Status code: (null).My code looks like this:
const GetSession = async () => {
const response = await fetch("https://localhost:7821/API/GetNewSession", {
method: "GET",
});
const data = await response.json();
setSession(data.session_id);
}It does seem to reach the API but seems to send an error back:
23:03:24.174 [Warning] [ComfyUI-0/STDERR] aiohttp.http_exceptions.BadStatusLine: 400, message:
23:03:24.176 [Warning] [ComfyUI-0/STDERR] Traceback (most recent call last):
23:03:24.177 [Warning] [ComfyUI-0/STDERR] File "C:\Users\Administrator\Desktop\AI\ImageGenerator\SwarmUI\dlbackend\comfy\python_embeded\Lib\site-packages\aiohttp\web_protocol.py", line 362, in data_received
23:03:24.177 [Warning] [ComfyUI-0/STDERR] messages, upgraded, tail = self._request_parser.feed_data(data)
23:03:24.178 [Warning] [ComfyUI-0/STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23:03:24.178 [Warning] [ComfyUI-0/STDERR] File "aiohttp\\_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
23:03:24.178 [Warning] [ComfyUI-0/STDERR] aiohttp.http_exceptions.BadStatusLine: 400, message:my next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "localhost",
port: "7821",
},
],
},
async headers() {
return [
{
// matching all API routes
source: "/api/:path*",
headers: [{ key: "Access-Control-Allow-Origin", value: "*" }],
},
];
},
};
export default nextConfig;