Closed exside closed 1 year ago
Thanks for reporting the issue. I will be looking for a solution and will fix it as soon as possible.
Any ideas where to look? Maybe i can help...
I think it's important to see between lines 218 and 238 of the server.ts file, that's where there might be a problem.
No activity
Well, I couldn't figure out what is the problem, but it persists, try it yourself:
['get', 'head'].map((method) => {
server[method]('/*', serveStatic(`${Deno.cwd()}/src`), async (ctx, next) => {
// console.log(ctx.req.method, ctx.req.url.match(/\.(?<ext>[^.]*?)(?=\?|#|$)/));
const ext = ctx.req.url.match(/\.(?<ext>[^.]*?)(?=\?|#|$)/)[1];
if ( ext ) {
const stats = await Deno.stat(`${Deno.cwd()}/src${new URL(ctx.req.url).pathname}`);
ctx.res.headers = new Headers({
'content-type': mime(ext),
'content-length': stats.size,
'last-modified': stats.mtime.toUTCString(),
});
}
// console.log(ctx.res);
await next();
});
});
Hi, first of all, great work on faster, love it so far!
I'm running into an issue when trying to handle HEAD requests (using them from the frontend to see if i need to fetch the entire file or if i can used the cached version in the browser, e.g. to check if the file was changed) for static files while also serving them statically via GET requests, i have this (played around with the order of the blocks, but no change):
when the
server.head()
handler is present, the HEAD requests work fine, but the GET requests stop working and stay as (pending) forever in the network monitor (browser side), if i remove it, HEAD requests return a 404 and the GET requests work as expected. I'm not sure where the issue is, i don't get errors on the server side and neither in the browser, the GET request is just stuck. Any ideas why that could be? maybe using the same middleware twice? but i checked the code, don't see why that would be an issue.