Skip to content

Commit a8be51d

Browse files
committed
🐛 Send Origin from book-file proxy to fix ORIGIN_NOT_FOUND
The server-side proxy added in 0f582c6 fetches `/ebook-cors/` server-to-server, which sends no Origin header — but the upstream CORS gate rejects an absent Origin with ORIGIN_NOT_FOUND, blocking the request before the Bearer JWT/ownership check runs. Attach our own whitelisted origin (BASE_URL) so the gate passes.
1 parent 882e768 commit a8be51d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

server/api/book-file.get.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export default defineEventHandler(async (event) => {
4646
const upstreamHeaders: Record<string, string> = {
4747
Authorization: `Bearer ${token}`,
4848
}
49+
// Server-to-server `fetch` sends no `Origin`, but `/ebook-cors/` rejects an
50+
// absent Origin with `ORIGIN_NOT_FOUND`. Send our own (whitelisted) origin so
51+
// its CORS gate passes; the real auth boundary upstream is the Bearer JWT.
52+
if (config.public.baseURL) upstreamHeaders.Origin = config.public.baseURL
4953
const rangeHeader = getHeader(event, 'range')
5054
if (rangeHeader) upstreamHeaders.Range = rangeHeader
5155

0 commit comments

Comments
 (0)