maybe this works

This commit is contained in:
Jeff Emmett 2024-12-07 16:02:10 -05:00
parent 63a3121f38
commit 30bdbfc958
1 changed files with 8 additions and 4 deletions

View File

@ -24,7 +24,8 @@ const { preflight, corsify } = cors({
const allowedOrigins = [ const allowedOrigins = [
'https://jeffemmett.com', 'https://jeffemmett.com',
'https://www.jeffemmett.com', 'https://www.jeffemmett.com',
'https://jeffemmett-canvas.jeffemmett.workers.dev' 'https://jeffemmett-canvas.jeffemmett.workers.dev',
'https://jeffemmett.com/board/*',
]; ];
// Always allow if no origin (like from a local file) // Always allow if no origin (like from a local file)
@ -92,11 +93,14 @@ const router = AutoRouter<IRequest, [env: Environment, ctx: ExecutionContext]>({
// bookmarks need to extract metadata from pasted URLs: // bookmarks need to extract metadata from pasted URLs:
.get('/unfurl', handleUnfurlRequest) .get('/unfurl', handleUnfurlRequest)
.get('/room/:roomId', async (request, env) => { .get('/room/:roomId', (request, env) => {
const id = env.TLDRAW_DURABLE_OBJECT.idFromName(request.params.roomId) const id = env.TLDRAW_DURABLE_OBJECT.idFromName(request.params.roomId)
const room = env.TLDRAW_DURABLE_OBJECT.get(id) const room = env.TLDRAW_DURABLE_OBJECT.get(id)
const response = await room.fetch(request.url) return room.fetch(request.url, {
return response headers: request.headers,
body: request.body,
method: request.method
})
}) })
.post('/room/:roomId', async (request, env) => { .post('/room/:roomId', async (request, env) => {