Domain degisikligi: fristy.net -> fristy.dev
CI / Code Health (pull_request) Successful in 22s
CI / Lint, Test & Build (pull_request) Successful in 46s
CI / Code Health (push) Successful in 25s
CI / Lint, Test & Build (push) Successful in 54s
Deploy / Build & Push Image (push) Successful in 56s
Deploy / Trigger Deploy (push) Successful in 1s
CI / Code Health (pull_request) Successful in 22s
CI / Lint, Test & Build (pull_request) Successful in 46s
CI / Code Health (push) Successful in 25s
CI / Lint, Test & Build (push) Successful in 54s
Deploy / Build & Push Image (push) Successful in 56s
Deploy / Trigger Deploy (push) Successful in 1s
This commit was merged in pull request #4.
This commit is contained in:
17 files changed
+40
-37
No files matched your search
+6
-6
@@ -9,9 +9,9 @@ afterEach(() => {
|
||||
function apiRequest(path: string, init?: { method?: string; origin?: string | null }): NextRequest {
|
||||
const headers = new Headers();
|
||||
if (init?.origin !== null) {
|
||||
headers.set("origin", init?.origin ?? "https://fristy.net");
|
||||
headers.set("origin", init?.origin ?? "https://fristy.dev");
|
||||
}
|
||||
return new NextRequest(`https://fristy.net${path}`, {
|
||||
return new NextRequest(`https://fristy.dev${path}`, {
|
||||
method: init?.method ?? "GET",
|
||||
headers,
|
||||
});
|
||||
@@ -21,19 +21,19 @@ describe("proxy /api/*", () => {
|
||||
it("answers OPTIONS preflight with CORS headers", () => {
|
||||
const response = proxy(apiRequest("/api/game/1", { method: "OPTIONS" }));
|
||||
expect(response.status).toBe(204);
|
||||
expect(response.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.net");
|
||||
expect(response.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.dev");
|
||||
expect(response.headers.get("Access-Control-Allow-Methods")).toBe("GET, OPTIONS");
|
||||
});
|
||||
|
||||
it("rejects foreign origins", () => {
|
||||
const response = proxy(apiRequest("/api/game/1", { origin: "https://evil.test" }));
|
||||
expect(response.status).toBe(403);
|
||||
expect(response.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.net");
|
||||
expect(response.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.dev");
|
||||
});
|
||||
|
||||
it("passes same-origin API requests with CORS headers", () => {
|
||||
const response = proxy(apiRequest("/api/game/1"));
|
||||
expect(response.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.net");
|
||||
expect(response.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.dev");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("proxy rate limit", () => {
|
||||
const limited = proxy(ipRequest("10.0.0.2"));
|
||||
expect(limited.status).toBe(429);
|
||||
expect(limited.headers.get("Retry-After")).toBe("60");
|
||||
expect(limited.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.net");
|
||||
expect(limited.headers.get("Access-Control-Allow-Origin")).toBe("https://fristy.dev");
|
||||
await expect(limited.json()).resolves.toEqual({ error: "Too many requests" });
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user