feat(server): choose cors origins by NODE_ENV and run docker in production
- allow the vite dev server origins in development and the compose port origins in production; CORS_ORIGINS overrides both - set NODE_ENV=production in the runtime docker image - document both settings in .env.example and the development docs - bump version to 1.19.3
This commit is contained in:
1 parent
6bc1b6fb19
commit
0ae807d68d
11 files changed
+90
-6
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { corsOrigins } from "../src/common/cors";
|
||||
|
||||
describe("corsOrigins", () => {
|
||||
it("allows the Vite dev server outside production", () => {
|
||||
for (const env of ["development", "test", ""]) {
|
||||
expect(corsOrigins(env, "")).toEqual([
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
it("allows the compose port in production", () => {
|
||||
expect(corsOrigins("production", "")).toEqual([
|
||||
"http://localhost:13000",
|
||||
"http://127.0.0.1:13000",
|
||||
]);
|
||||
});
|
||||
|
||||
it("uses CORS_ORIGINS when set, in any environment", () => {
|
||||
const override = " https://liqa.example.com , http://localhost:8080,";
|
||||
for (const env of ["development", "production"]) {
|
||||
expect(corsOrigins(env, override)).toEqual([
|
||||
"https://liqa.example.com",
|
||||
"http://localhost:8080",
|
||||
]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user