mirror of
https://github.com/coder/code-server.git
synced 2026-04-12 18:28:17 -05:00
Add skip-auth-preflight flag to allow OPTIONS requests through proxy (#7284)
This commit is contained in:
@@ -108,6 +108,8 @@ describe("parser", () => {
|
||||
|
||||
["--abs-proxy-base-path", "/codeserver/app1"],
|
||||
|
||||
"--skip-auth-preflight",
|
||||
|
||||
["--session-socket", "/tmp/override-code-server-ipc-socket"],
|
||||
|
||||
["--host", "0.0.0.0"],
|
||||
@@ -146,6 +148,7 @@ describe("parser", () => {
|
||||
"bind-addr": "192.169.0.1:8080",
|
||||
"session-socket": "/tmp/override-code-server-ipc-socket",
|
||||
"abs-proxy-base-path": "/codeserver/app1",
|
||||
"skip-auth-preflight": true,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -268,6 +268,21 @@ describe("proxy", () => {
|
||||
const text = await resp.text()
|
||||
expect(text).toBe("app being served behind a prefixed path")
|
||||
})
|
||||
|
||||
it("should not allow OPTIONS without authentication by default", async () => {
|
||||
process.env.PASSWORD = "test"
|
||||
codeServer = await integration.setup(["--auth=password"])
|
||||
const resp = await codeServer.fetch(proxyPath, { method: "OPTIONS" })
|
||||
expect(resp.status).toBe(401)
|
||||
})
|
||||
|
||||
it("should allow OPTIONS with `skip-auth-preflight` flag", async () => {
|
||||
process.env.PASSWORD = "test"
|
||||
codeServer = await integration.setup(["--auth=password", "--skip-auth-preflight"])
|
||||
e.post("/wsup", (req, res) => {})
|
||||
const resp = await codeServer.fetch(proxyPath, { method: "OPTIONS" })
|
||||
expect(resp.status).toBe(200)
|
||||
})
|
||||
})
|
||||
|
||||
// NOTE@jsjoeio
|
||||
|
||||
Reference in New Issue
Block a user