Marvin Hagemeister
c11cf7b41a
feat: expose layouts and pages on App ( #3086 )
...
This PR extracts the functionality from the `fs_routes` plugin and
exposes it onto `App`. These are the new APIs:
- `app.layout(pattern, route)`
- `app.onError(pattern, route)`
- `app.notFound(pattern, route)`
- `app.route(pattern, route)`
This also removes the need for `.use(staticFiles())`. This line can be
safely removed.
Fixes https://github.com/denoland/fresh/issues/3040
Fixes https://github.com/denoland/fresh/issues/3033
Fixes https://github.com/denoland/fresh/issues/2591
Fixes https://github.com/denoland/fresh/issues/950
Fixes https://github.com/denoland/fresh/issues/1918
2025-07-14 19:27:48 +02:00
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
Luca Casonato
b4fd717c6c
fix: reset span name and http.route in static file middleware ( #2856 )
2025-04-23 14:35:39 +02:00
Luca Casonato
65d61bd1d5
feat: add open telemetry instrumentation ( #2786 )
...
This commit adds some useful automatic instrumentation for when users
are using `--unstable-otel`:
- Fresh renames the span for incoming HTTP requests to `$METHOD $ROUTE`
and the `http.route` attribute is added.
- Fresh creates a span around FS route handlers, showing whether they
returned a response or data.
- Fresh creates a span around async components, showing how long they
took to execute.
- Fresh adds a span around preact rendering, showing how long rendering
takes.
- Fresh adds a span around static file serving, showing how long it took
and whether there were requests without a cache bust key.
We can improve this in the future with more telemetry, such as metrics.
2024-12-10 15:03:50 +01:00
Luca Casonato
6b685dde9f
fix: serve internal JS from path containing build ID ( #2753 )
...
Previously imported chunks were not cached at all. They are now cached
properly with immutable cache headers.
2024-11-08 11:44:15 +01:00
Luca Casonato and Marvin Hagemeister
407987589f
feat: support fresh projects that are part of a workspace ( #2716 )
...
Also a performance improvement & bug fix in the tailwind plugin.
---------
Co-authored-by: Marvin Hagemeister <marvin@deno.com >
2024-10-17 17:08:24 +02:00
Felix
126f492ea0
fix: decode static file paths ( #2642 )
...
Fixes #2613
2024-09-06 10:49:07 +02:00
Luca Casonato and Marvin Hagemeister
1f9fb91c4d
fix: add proper cache control headers ( #2617 )
...
The whole point of `asset()` is to enable caching. Yet we were not
adding cache control headers... :D
---------
Co-authored-by: Marvin Hagemeister <marvin@deno.com >
2024-08-13 14:15:25 +02:00
Marvin Hagemeister
72811da29b
fix: etag caching HTTP headers ( #2504 )
2024-06-25 10:21:43 +02:00
Luca Casonato
c3ec742a65
feat: import fresh from fresh ( #2479 )
...
Instead of importing as `@fresh/core`.
2024-06-05 14:51:35 +02:00
Marvin Hagemeister
d613c6a6ba
fix: islands not working with basePath ( #2496 )
2024-06-05 09:02:27 +02:00
Marvin Hagemeister
287929e4d2
major: import Fresh 2.0 code ( #2449 )
...
🎉
2024-05-24 09:40:08 +02:00