satyarohith / sift

Sift is a routing and utility library for Deno Deploy.

Home Page:https://deno.land/x/sift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serveStatic doesn't work with deploy: "Request with GET/HEAD method cannot have body."

orgsofthq opened this issue · comments

The framework doesn't seem to work with serving static files while using Deno Deploy.

The body seems to be getting set somewhere, which causes an error when a new Request object is created. This doesn't seem to happen when using deployctl locally.

repro

mod.ts

import { serveStatic } from "https://deno.land/x/sift@0.3.5/mod.ts";

serve({
  "/": serveStatic("index.html", { baseUrl: import.meta.url }),
});

http response

{"error":"Request with GET/HEAD method cannot have body."}

deploy logs

0 | [Info] | GET / 1ms 500
1 | [Error] | Error serving request: TypeError: Request with GET/HEAD method cannot have body.
     at new Request (deno:ext/fetch/23_request.js:323:15)
     at Object./ (https://deno.land/x/sift@0.3.5/mod.ts:138:36)
     at async handleRequest (https://deno.land/x/sift@0.3.5/mod.ts:63:36)
     at async Event.respondWith (deno:ext/http/01_http.js:151:16)

Thanks for opening the issue. This is now fixed in 0.4.0.

import { serveStatic } from "https://deno.land/x/sift@0.4.0/mod.ts";

serve({
  "/": serveStatic("index.html", { baseUrl: import.meta.url }),
});

@satyarohith it seems like there is still an issue with the implementation.

Using the snippet above, I get..

"Not a directory (os error 20), open '[my_path]/index.html/'"

It tries to resolve to ./index.html/ instead of the intended ./index.html.

Lines 165-167 in mod.ts append a / to any route when params?.fileName is null, which it seems to always be.

@organic-software The issue is fixed in #48. Try 0.4.1 and let me know if you still encounter the issue.