feat: Add GitHub Actions workflow to deploy 1000h entry website
This commit is contained in:
26
entry/index.js
Normal file
26
entry/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
async function handleRequest(request, env) {
|
||||
const { host, pathname } = new URL(request.url);
|
||||
// for the root path, forward to Portal
|
||||
// for other paths, forward to VTP
|
||||
if (pathname === '/') {
|
||||
return forwardToPortal(request, env);
|
||||
} else {
|
||||
return forwardToVtp(request, env);
|
||||
}
|
||||
}
|
||||
|
||||
async function renderInternalError(msg) {
|
||||
return new Response(`Internal Error: ${msg}`, {
|
||||
status: 500,
|
||||
headers: { 'Content-Type': 'text/html' }
|
||||
});
|
||||
}
|
||||
|
||||
async function forwardToVtp(request, env) {
|
||||
return await env.vtp.fetch(request)
|
||||
}
|
||||
|
||||
async function forwardToPortal(request, env) {
|
||||
return await env.portal.fetch(request)
|
||||
}
|
||||
14
entry/wrangler.toml
Normal file
14
entry/wrangler.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
name = "1000h-entry"
|
||||
main = "index.js"
|
||||
workers_dev = false
|
||||
compatibility_date = "2023-03-23"
|
||||
|
||||
routes = ["next.1000h.org/*"]
|
||||
services = [
|
||||
{ binding = "vtp", service = "1000-hours-prod" },
|
||||
{ binding = "portal", service = "1000h-portal" },
|
||||
]
|
||||
|
||||
[vars]
|
||||
HOST = "https://next.1000h.org"
|
||||
|
||||
Reference in New Issue
Block a user