mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add safeguard for incorrectly configured proxies
This commit is contained in:
parent
7a591a024e
commit
c28628ebb3
4 changed files with 58 additions and 4 deletions
|
|
@ -35,4 +35,29 @@ describe("API Tests", () => {
|
|||
expect(data.error).toBeString();
|
||||
expect(data.error).toContain("https://stackoverflow.com");
|
||||
});
|
||||
|
||||
test("try sending a request with a different origin", async () => {
|
||||
if (new URL(config.http.base_url).protocol === "http:") {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await sendTestRequest(
|
||||
new Request(
|
||||
new URL(
|
||||
"/api/v1/instance",
|
||||
base_url.replace("https://", "http://"),
|
||||
),
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
expect(response.status).toBe(400);
|
||||
const data = await response.json();
|
||||
expect(data.error).toContain("does not match base URL");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue