Skip to content
Open
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
2 changes: 1 addition & 1 deletion api/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@std/http": "jsr:@std/http@^1.0.22"
},
"name": "@01edu/api",
"version": "0.1.6",
"version": "0.1.7",
"license": "MIT",
"exports": {
"./context": "./context.ts",
Expand Down
6 changes: 6 additions & 0 deletions api/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ const forAppEnv =
* ```
*/
export const PROD: EnvGetter = forAppEnv('prod')

export const BASE_URL: string = PROD('BASE_URL', '/')
if (!BASE_URL.startsWith('/') || !BASE_URL.endsWith('/')) {
throw Error('incorrect BASE_URL: must start and end with /')
}

/**
* TEST env getter
*
Expand Down
3 changes: 2 additions & 1 deletion api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { type RequestContext, runContext } from './context.ts'
import { respond, ResponseError } from './response.ts'
import { now } from '@01edu/time'
import type { Awaitable } from '@01edu/types'
import { BASE_URL } from './env.ts'

type Handler = (ctx: RequestContext) => Awaitable<Response>
/**
Expand Down Expand Up @@ -99,7 +100,7 @@ export const server = (
setCookie(res.headers, {
name: 'trace',
value: String(ctx.trace),
path: '/',
path: BASE_URL,
secure: true,
httpOnly: true,
sameSite: 'Lax',
Expand Down