mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Allow 127.X.X.X loopback hostnames
This commit is contained in:
parent
9653aca0d2
commit
2a6c4e9f34
@ -1,7 +1,7 @@
|
||||
import { DomainConfigJson } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
||||
|
||||
export function validateUrl(url: string, domains: DomainConfigJson[], allowLocalhost: boolean): boolean {
|
||||
if (allowLocalhost && (new URL(url).hostname === "localhost" || new URL(url).hostname === "127.0.0.1")) {
|
||||
if (allowLocalhost && (new URL(url).hostname === "localhost" || new URL(url).hostname.match(/^127\.\d+\.\d+\.\d+$/))) {
|
||||
return true;
|
||||
}
|
||||
return domains.some((domain) => {
|
||||
|
||||
@ -382,7 +382,18 @@ export class StackClientInterface {
|
||||
},
|
||||
};
|
||||
|
||||
const rawRes = await fetch(url, params);
|
||||
let rawRes;
|
||||
try {
|
||||
rawRes = await fetch(url, params);
|
||||
} catch (e) {
|
||||
if (e instanceof TypeError) {
|
||||
// Network error, retry
|
||||
console.log("Stack detected a network error, retrying.", e);
|
||||
return Result.error(e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
const processedRes = await this._processResponse(rawRes);
|
||||
if (processedRes.status === "error") {
|
||||
// If the access token is expired, reset it and retry
|
||||
|
||||
Loading…
Reference in New Issue
Block a user