Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { getRuntime } from "../apps/lab-guide/cloud/runtime.mjs";

export default {
fetch(request) {
return getRuntime().fetch(request);
},
};
15 changes: 15 additions & 0 deletions tests/repository-contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,18 @@ test("implementation roots exist", () => {
assert.equal(existsSync(resolve(root, path)), true, `${path} is missing`);
}
});

test("Vercel origin exposes only the ExamServer lab namespace", () => {
const config = JSON.parse(read("vercel.json"));

assert.equal(config.outputDirectory, "apps/lab-guide/dist/client");
assert.deepEqual(
config.rewrites.map(({ source }) => source),
["/api/lab/:path*", "/lab", "/lab/:path*"],
);
assert.equal(
config.redirects[0].destination,
"https://exam-server-one.vercel.app/lab",
);
assert.equal(existsSync(resolve(root, "api/index.mjs")), true);
});
54 changes: 54 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"installCommand": "npm ci --prefix apps/lab-guide",
"buildCommand": "npm --prefix apps/lab-guide run build",
"outputDirectory": "apps/lab-guide/dist/client",
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "Content-Security-Policy",
"value": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'"
},
{
"key": "Permissions-Policy",
"value": "camera=(), microphone=(), geolocation=()"
},
{
"key": "Referrer-Policy",
"value": "no-referrer"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
}
]
}
],
"rewrites": [
{
"source": "/api/lab/:path*",
"destination": "/api?__route=:path*"
},
{
"source": "/lab",
"destination": "/index.html"
},
{
"source": "/lab/:path*",
"destination": "/:path*"
}
],
"redirects": [
{
"source": "/",
"destination": "https://exam-server-one.vercel.app/lab",
"permanent": false
}
]
}
Loading