Skip to content

Commit

Permalink
Fix CORS stuff when requesting other origins (ie, the AI servers)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Oct 24, 2023
1 parent 5c0d92d commit 97154f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ function request(method: Method): RequestFunction {
}
}

const same_origin = url.indexOf("://") < 0 || url.indexOf(window.location.origin) === 0;

fetch(url, {
signal,
method,
credentials: "include",
credentials: same_origin ? "include" : undefined,
keepalive: true,
mode: csrf_safe ? "no-cors" : "cors",
mode: same_origin ? (csrf_safe ? "no-cors" : "cors") : undefined,
cache: cacheable ? "default" : "no-cache",
body: prepared_data as any,
headers,
Expand Down

0 comments on commit 97154f5

Please sign in to comment.