diff --git a/deno.json b/deno.json index fb36792..8b05212 100644 --- a/deno.json +++ b/deno.json @@ -1,7 +1,7 @@ { "name": "@andyburke/serverus", "description": "A flexible HTTP server for mixed content. Throw static files, markdown, Typescript and (hopefully, eventually) more into a directory and serverus can serve it up a bit more like old-school CGI.", - "version": "0.14.0", + "version": "0.14.1", "license": "MIT", "exports": { ".": "./serverus.ts", diff --git a/handlers/spa.ts b/handlers/spa.ts index 75821ee..fa82343 100644 --- a/handlers/spa.ts +++ b/handlers/spa.ts @@ -87,17 +87,9 @@ export const HANDLERS: Partial> = { if (index_file_stat.isFile) { const processed: string = await load_html_with_ssi(index_file_path); - - const accepts = request.headers.get('accept') ?? 'text/html'; - if (!['*/*', 'text/html', 'text/plain'].includes(accepts)) { - return new Response('unsupported accepts header for SPA: ' + accepts, { - status: 400 - }); - } - return new Response(processed, { headers: { - 'Content-Type': accepts === '*/*' ? 'text/html' : accepts + 'Content-Type': request.headers.get('accept')?.indexOf('text/plain') !== -1 ? 'text/plain' : 'text/html' } }); } @@ -111,7 +103,7 @@ export const HANDLERS: Partial> = { } }, - OPTIONS: async (request: Request, normalized_path: string): Promise => { + OPTIONS: async (_request: Request, normalized_path: string): Promise => { const spa_root = await find_spa_file_root(normalized_path); if (!spa_root) { return; @@ -123,13 +115,6 @@ export const HANDLERS: Partial> = { const index_file_stat = await Deno.stat(index_file_path); if (index_file_stat.isFile) { - const accepts = request.headers.get('accept') ?? 'text/html'; - if (!['*/*', 'text/html', 'text/plain'].includes(accepts)) { - return new Response('unsupported accepts header for SPA: ' + accepts, { - status: 400 - }); - } - const allowed = ['GET', 'HEAD', 'OPTIONS']; return new Response('', {