Christian Svensson
|
f15f225576
|
fix: make static folders with dot such as .well-known allowed (#2929)
This PR intends to address an error logged when opening a DevTools in a
Chromium based browser while using Fresh in dev mode.
<details>
<summary><strong>See error</strong></summary>
```
Error: Processed file resolved outside of static dir C:\Users\<name>\fresh-site\src\static\.well-known\appspecific\com.chrome.devtools.json
at MemoryBuildCache.readFile (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/dev/dev_build_cache.ts:81:13)
at eventLoopTick (ext:core/01_core.js:178:7)
at async freshStaticFiles (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/static_files.ts:30:18)
at async FreshReqContext.fn (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/mod.ts:99:18)
at async https://jsr.io/@fresh/core/2.0.0-alpha.29/src/dev/middlewares/error_overlay/middleware.tsx:15:14
at async FreshReqContext.fn (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/mod.ts:99:18)
at async fn (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/mod.ts:99:18)
at async https://jsr.io/@fresh/core/2.0.0-alpha.29/src/app.ts:232:16
at async mapped (ext:deno_http/00_serve.ts:407:18)
```
</details>
DevTools tries to load a
`<root>/static/.well-known/appspecific/com.chrome.devtools.json` file,
which incorrectly is flagged as "outside" the static directory, and thus
generates errors instead of 404.
Maybe hidden folders (starting with `.`) in `/static` should be opt-in
though? I'm not sure if anyone puts folders with `.` prefix inside
`static/` without intending them to be accessible?
- `..` throws errors (outside staticDir)
- `.` returns "missing file" (unless `config.allowHiddenFolders` is
true)
## Automatic workspace folders
I think a follow-up PR could be for the Dev `Builder` to also implement
support for [Automatic workspace
folders](https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md),
by returning JSON content automatically at
`.well-known/appspecific/com.chrome.devtools.json`.
I think a good first step is to allow `.<folder-name>`, especially since
`.well-known/` has [many valid
use-cases](https://en.wikipedia.org/wiki/Well-known_URI), and as such is
not unreasonable to want to add static files in.
|
2025-05-13 10:03:05 +02:00 |
|