396 Commits
Author SHA1 Message Date
paula 8c552d05d1 f-update-url 2026-11-11 17:16:21 -03:00
paula 3866b47741 Button partials with any methods 2026-11-11 16:56:47 -03:00
paula 8400c019e0 Make partials support any http method :3 2026-11-11 16:27:12 -03:00
paula 216d54a0ae Start renaming 2026-11-11 11:45:20 -03:00
Luca Casonato 86d6cdeb33 www: change domain to usefresh.dev (#3831) 2026-06-03 16:35:21 +02:00
William WeissandBartek Iwańczuk acd04e13f8 docs: websockets do not work with vite dev server pre-Deno 2.8 and Fresh 2.4 (#3822)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2026-05-27 07:46:33 +02:00
Bartek Iwańczuk 562b82f554 docs: add Builder-to-Vite migration guide (#3819)
Fresh 2 projects created with `--builder` (or predating the Vite plugin)
had no documented path for switching to the Vite-backed build, so users were
left to diff a freshly generated project against their own. This adds a
"Migrating from the Builder to Vite" section to the existing Vite
advanced doc, walking through the `deno.json` updates, the `dev.ts` →
`vite.config.ts` swap, the new `client.ts` entry and CSS move out of `static/`, the
Tailwind plugin switch, and a short verification checklist.

Placed inline in `docs/latest/advanced/vite.md` rather than as a new
migration-guide page so all Vite content stays in one place; no `toc.ts`
change needed.
2026-05-26 15:24:22 +02:00
Bartek IwańczukandJosh Collinsworth cb6d02d2eb feat: refresh landing page for Fresh 2.3 (#3775)
- Update HelloBar to announce Fresh 2.3 with feature callouts
(WebSockets, View Transitions, Temporal API)
- Rework hero section: new headline ("The framework so simple, you
already know it"), descriptive subtitle, moved CTA to left
- Remove old Simple section, add "Take a tour of Fresh" heading before
showcase
- Add new showcase sections: View Transitions, API Routes/Handlers,
WebSockets, `<Head>` element, OpenTelemetry
- Fix broken Deco showcase image (missing `/showcase/` directory)
- Fix syntax highlighting in Simple section (was using raw `<pre>`
instead of Prism)
- Update RenderingSection to use Temporal API instead of Date API
- Fix cursor styles on Forms and Partials interactive demos
- Move WebSocket docs from Examples to Advanced in TOC
- Densify all showcase sections: smaller headings, code blocks, icons,
demo boxes, arrows, and tighter spacing

---------

Co-authored-by: Josh Collinsworth <joshuajcollinsworth@gmail.com>
2026-04-24 18:03:22 +02:00
Bartek Iwańczuk 0ab5a2ab28 feat: add first-class WebSocket support via ctx.upgrade() and app.ws() (#3774)
## Summary

- **`ctx.upgrade()`** on the `Context` class with two overloads:
- **Bare mode**: `ctx.upgrade()` or `ctx.upgrade(options)` returns `{
socket, response }` for manual event wiring
- **Managed mode**: `ctx.upgrade(handlers)` accepts `{ open, message,
close, error }` and returns the upgrade `Response` directly
- **`app.ws(path, handlers, options?)`** shorthand that registers a GET
route with automatic WebSocket upgrade (managed mode only)
- Both support `idleTimeout` and `protocol` options forwarded to
`Deno.upgradeWebSocket()`
- Throws `HttpError(400)` on non-WebSocket requests
- Case-insensitive `Upgrade` header check per RFC 6455 §4.2.1
- Exports `WebSocketHandlers` and `WebSocketUpgradeOptions` types from
`fresh`
- Full documentation page with examples for managed mode, bare mode,
broadcast chat, and client-side usage
2026-04-22 19:17:43 +02:00
Bartek IwańczukandClaude Opus 4.6 28cce5f607 feat: add _freshIndicator support for partial form submits (#3753)
## Summary
- Extends the `_freshIndicator` loading signal to form submissions, not
just anchor clicks
- Checks the submitter element first, falling back to the form element
- Wraps the fetch in try/finally to ensure the indicator resets on
success or failure
- Adds 3 browser tests: indicator on button, indicator on form, and
submitter-over-form precedence

Closes #3504

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 12:21:39 +02:00
Bartek IwańczukandClaude Opus 4.6 07878fcce9 feat: add trustProxy option to respect X-Forwarded-* headers (#3757)
## Summary
- Adds `trustProxy` option to `FreshConfig` (default: `false`)
- When enabled, the handler reads `X-Forwarded-Proto` and
`X-Forwarded-Host` headers and rewrites `ctx.url` so it reflects the
actual client-facing URL
- Useful for apps running behind nginx, Caddy, or other reverse proxies
where `ctx.url` would otherwise return `http://` instead of `https://`

Closes #2660

## Usage
```ts
const app = new App({ trustProxy: true });
```

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 07:53:24 +00:00
Bartek IwańczukandClaude Opus 4.6 990aeb03f3 feat: support multiple staticDir entries (#3759)
## Summary
- `staticDir` now accepts `string | string[]` in both the **Vite
plugin** (`FreshViteConfig`) and the **Builder API** (`BuildOptions`)
- When multiple directories are specified, they are searched in order
and the first match wins
- **Vite plugin**: first dir maps to Vite's native `publicDir`; extra
dirs are served manually in the dev server and walked during production
builds
- **Builder API**: both `MemoryBuildCache` (dev) and `DiskBuildCache`
(prod) iterate over all directories
- Updated tailwind v3 plugin to use `config.root` instead of
`path.dirname(config.staticDir)`
- Docs updated: `static-files.md`, `vite.md`, `builder.md`

Closes #3105

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 07:49:32 +00:00
Bartek IwańczukandClaude Opus 4.6 fc0ff66b80 fix: active links consider query params and respect existing aria-current (#3755)
## Summary
- `matchesUrl()` now considers query parameters — links with query
params that don't match the current URL get `Ancestor` instead of
`Current` status
- Links with a user-set `aria-current` attribute are left untouched
(both server and client side), fixing daisyUI tab components and similar
use cases
- Client-side `updateLinks()` passes search params and respects user-set
attributes

Closes #3474

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 09:42:02 +02:00
Bartek IwańczukandClaude Opus 4.6 895bcacdae fix: architecture diagram unreadable in dark mode (#3752)
## Summary
- The inline HTML/CSS flow diagram in `docs/concepts/architecture` was
broken — marked's smartypants text transforms corrupted the `<style>`
block, stripping all styling
- Replaced with a standalone SVG
(`www/static/docs/architecture-flow-v2.svg`) using theme-neutral
mid-gray colors that are readable on both light and dark backgrounds

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 11:08:11 +02:00
Bartek IwańczukandClaude Opus 4.6 3a51f82da6 fix: use deno run for init instead of deno create before 2.3.0 (#3746)
## Summary
- Reverts all references from `deno create @fresh/init` back to `deno
run -Ar jsr:@fresh/init` across docs, READMEs, homepage, and CLI help
text
- Removes the deprecation warning in `packages/init/src/mod.ts` that
told users to switch to `deno create`

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 09:19:14 +02:00
Bartek IwańczukandClaude Opus 4.6 400e217c5e feat: add View Transitions API support for client-side navigation (#3708)
## Summary

- Integrates the [View Transitions
API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API)
into Fresh's existing partials system
- Opt-in via `f-view-transition` attribute, progressive enhancement
(falls back gracefully)
- Wraps all navigation types (link clicks, popstate, form submissions)
in `document.startViewTransition()`

## Usage

```html
<body f-client-nav f-view-transition>
  <!-- your app -->
</body>
```

Customize animations with standard CSS:
```css
::view-transition-old(root) {
  animation: fade-out 0.2s ease-in;
}
::view-transition-new(root) {
  animation: fade-in 0.2s ease-out;
}
```

Per-element transitions work via `view-transition-name`:
```css
.sidebar { view-transition-name: sidebar; }
```

## Design decisions

- **Opt-in** — only activates when `f-view-transition` attribute is
present, can be disabled with `f-view-transition="false"`
- **Progressive** — falls back to regular partial updates when the
browser doesn't support the View Transitions API
- **Minimal** — 35 lines of implementation, integrates into existing
partials infrastructure rather than building a parallel navigation
system

Closes https://github.com/denoland/fresh/issues/3458

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:56:37 +00:00
Bartek IwańczukandClaude Opus 4.6 dc2324807c feat: add nonce support for inline style and script tags in CSP (#3709)
## Summary
- Auto-inject `nonce` attribute onto inline `<script>` and `<style>`
tags during server rendering
- Add `useNonce` option to the CSP middleware that replaces
`'unsafe-inline'` with per-request `'nonce-{value}'` directives
- Expose render nonce via `X-Fresh-Nonce` response header (internal,
stripped by CSP middleware)

## Usage

```ts
app.use(csp({ useNonce: true }));
```

This locks down the CSP policy so only Fresh-rendered inline
scripts/styles are allowed. Each request gets a unique nonce.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:45:13 +02:00
566a6ce5e4 feat: add IP filter middleware (#3035)
Closes #3011

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:43:52 +02:00
669f62a32a fix: prevent 404 for routes consisting solely of an optional parameter (#2798)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:27:18 +02:00
a79b155e79 fix: make <Head> work in client (#3252)
Closes #3310

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:21:39 +02:00
ad8ec0fa42 docs: fix markdown docs (#3459)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:10:48 +00:00
Bartek IwańczukandClaude Opus 4.6 075dfb73b2 feat: inject traceparent meta tag when OpenTelemetry is active (#3729)
Closes #2830

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 18:51:12 +00:00
420a8cfb8e docs: fix misleading main.tsx filenames (#3477)
Closes #3476

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 18:38:14 +00:00
Bartek IwańczukandClaude Opus 4.6 be467d3cdb fix: warn when Partial with append/prepend mode is missing key prop (#3738)
## Summary
- Adds a `console.warn` during SSR when a `<Partial>` uses
`mode="append"` or `mode="prepend"` without a `key` prop
- Without a key, Preact cannot correctly reconcile prepended/appended
children, leading to subtle rendering bugs
- No warning for `mode="replace"` (default) since keys aren't required
there

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:33:14 +02:00
Bartek IwańczukandClaude Opus 4.6 103427f9da docs: comprehensive documentation audit, fixes, and website improvements (#3712)
## Summary

Full documentation audit and fixes for Fresh 2.x docs. Addresses every
issue identified in the [audit
report](https://gist.github.com/bartlomieju/91ddb08c23552f642d2073c0e9a36102).

### Critical fixes
- Remove 4 TODO placeholders (app.md, plugins/index.md)
- Fix 4 broken code examples (layouts syntax error, routing missing ctx,
csrf wrong import, getting-started unused prop)
- Fix 3 copy-pasted frontmatter descriptions (context, env-vars, app)
- Fix CSRF page describing CORS instead of CSRF

### New pages (8)
- **Architecture** — request lifecycle diagram, server-first rendering,
islands architecture
- **Data Fetching** — handlers, page(), type-safe data passing, async
components, PageProps reference
- **Signals** — useSignal, computed, props, shared state, serialization
- **Serialization** — supported types, what can't be serialized,
circular refs, pitfalls
- **API Routes** — handler-only routes, method-specific, catch-all,
programmatic
- **Common Patterns** — protected routes, redirects, cookies,
WebSockets, streaming, content negotiation, subdomain routing, proxying,
lazy-loading islands
- **API Reference** — all exports from fresh, fresh/runtime, fresh/dev
- **OpenTelemetry** — what's instrumented, enabling tracing, Deno Deploy

### Expanded pages (6)
- **Routing** — matching priority, HTTP methods, HEAD fallback,
file-based handlers
- **Vite plugin** — HMR, plugin composition, internals, debugging
- **Deno Deploy** — build config, env vars, custom domains,
troubleshooting
- **deno compile** — cross-compilation, limitations
- **Error handling** — expanded HttpError with message param, import
paths
- **Plugins index** — plugin authoring guidance, built-in plugin list

### Structural improvements
- Update all 3 index pages (concepts, advanced, examples) with links to
every sub-page
- Cross-link the two Layouts pages (file-based vs programmatic)
- Resolve contradictory build commands (remove legacy dev.ts references)
- Add "next steps" to Getting Started
- Explain `(_islands)` and `(_components)` directories in file routing
- Document `basePath`, `assetSrcSet()`, `IS_BROWSER`, route `css` option
- Add PR guidelines to Contributing page
- Add Deno version requirements to Introduction

### Docs fixes from issue triage
- **Docker deployment** — add missing `deno install --allow-scripts`
step, remove stale `deno cache`, fix CMD (#3500)
- **Deployment index** — add install step before build (#3500)
- **Static files** — add tip about root-relative URLs (#3482), add image
optimization section with vite-imagetools, CDN services, best practices
(#671)
- **main.ts vs main.tsx** — fix examples showing JSX in main.ts, add tip
about serverEntry config (#3476)
- **Head component** — clarify dedup precedence: last-rendered wins
(#2749)
- **Islands** — add custom elements / web components section (#2741)
- **Sharing state** — rewrite cart example to avoid shared module-level
signals (#2437, #1877)
- **Common patterns** — add subdomain routing (#603), proxying requests
(#361), lazy-loading islands (#565)

### Website fixes
- **Canary redirects** — catch-all `/docs/canary/...` → `/docs/...`
redirect (#3375)
- **Recipe partials** — redirect direct access to recipe routes to
homepage (#2559)
- **Homepage** — add progressive complexity code examples to Simple
section (#2755)

### Image reference fixes
- Rename `getting-started-3-cotuntdown.png` →
`getting-started-3-countdown.png`
- Fix 1.x partials image path

### Grammar/typos
- 11 corrections across 12 files

### CI
- Add `docs/check_images_test.ts` — verifies all markdown image
references resolve to existing files in `www/static/`

Closes #3514
Closes #3476
Closes #3591
Closes #2876
Closes #2075
Closes #1612
Closes #1535
Closes #527
Closes #3059
Closes #3695
Closes #3548
Closes #3500
Closes #3482
Closes #3375
Closes #2749
Closes #2741
Closes #2559
Closes #2437
Closes #671
Closes #361

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 18:22:33 +00:00
Bartek IwańczukandClaude Opus 4.6 2c94a1da2e ci: add link checker to CI (#3707)
## Summary
- Rewrite `tools/check_links.ts` to be more robust (inspired by
denoland/docs' `better_link_checker.ts`)
- Add `deno task check:links` to `deno.json`
- Wire it into CI as a new step (Ubuntu + v2.x only, after `build-www`)
- Add missing `docs/latest/examples/index.md` to fix broken
`/docs/examples` link
- Crawl up to 10 pages concurrently for faster link checking

## What the link checker does
1. Builds the www site with Vite
2. Launches a production server
3. Crawls all internal links starting from the root (10 pages
concurrently)
4. Reports broken links (4xx/5xx) with referrer info
5. Detects empty `href` attributes
6. Prints a summary at the end instead of throwing on first failure

Improvements over the old `check_links.ts`:
- Doesn't throw on first 404 — collects all failures and reports at the
end
- Detects empty hrefs
- Skips non-HTML content, fragment-only links, external links, and
common static file extensions
- Shows referrer for each broken link so you know where to fix it

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:49:17 +00:00
9509b087ff docs: add contributing section (#3384)
Adds a Contributing section to the Fresh documentation covering:

- Repository structure and package layout
- Getting started (clone, `deno task ok`)
- Development workflow (docs site, vite demo, `links` for external
projects)
- Testing (commands, conventions, known local issues)

Single page at `docs/latest/contributing/index.md`.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 07:39:20 +00:00
8bf05a0127 docs: add clarification for assets/static (#3525)
This adds a short clarification how imported assets vs. static files get
handled now with Vite to the existing documentation for static files.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:54:04 +01:00
88bef6c2ef docs: add example for session management (#3594)
Resolves: #1216

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:49:01 +01:00
Douglas MouraandBartek Iwańczuk 76a9ca7d1e fix: typo in Subscribe page handler reference (#3669)
This PR removes an extra `s` on the type definition of the handler for
the page.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2026-03-25 17:59:21 +00:00
sck451 d27e20ce5e docs: fix spelling error in index.md (#3658)
Corrected the spelling of 'middelwares' to 'middlewares'.
2026-02-11 14:24:36 +01:00
madflow 9196656efb docs: fix typo in getting started documentation (#3675)
Corrected the typo 'span' to 'spawn' in the setup instructions.
2026-02-11 14:20:06 +01:00
Freddy Alvarado R a1000cbb59 docs: Update daisyUI installation instructions and file path (#3592)
The directory where the stylesheet is located is updated.
2025-11-20 09:50:35 +01:00
Marvin Hagemeister 5e94dfe9fd fix: switch to nodeModulesDir: "manual" (#3588)
The `"auto"` value causes all kinds of race conditions between various
processes trying to auto install their view of dependencies.
2025-10-30 14:50:49 +01:00
Roy Revelt 45bb094bd6 docs: fix two typos (#3577)
fixes two tiny erros in the docs
2025-10-29 17:59:23 +01:00
Brett Chalupa 662f795ae8 feat: add @/ path alias to generated projects (#3562)
Sets up `@/` as the default path alias in newly generated Fresh
projects, following the official Deno documentation guidelines. This
allows developers to use `@/` for absolute imports from the project root
instead of relative paths. This is especially convenient to remove
import that require deeply traversing up the directory tree.

The `@/` alias is now included in the imports section of deno.json for
all new projects, enabling cleaner import statements like:

```
import { Button } from "@/components/Button.tsx";
```

Fixes #3485
2025-10-21 11:24:36 +02:00
Devon Wells a2c9350cc4 docs: typos in define helpers page (#3533)
## Summary

Minor typos in define docs page I noticed while onboarding to Fresh 2.
2025-10-07 12:48:29 +02:00
Marvin Hagemeister c93e19dfbd docs: add Deno upgrade section (#3526) 2025-10-06 08:08:30 +02:00
fry69 8e9dcc087f docs: troubleshoot deploy error message (#3511)
This adds one sentence to the "My deployment won't start" section
mentioning the common `ISOLATE_INTERNAL_FAILURE` error message, so it
can get found via search.

See also discussion in Discord ->
https://discord.com/channels/684898665143206084/1422792167797166121
2025-10-02 23:47:48 +02:00
fry69 1e94e1c9c5 docs: troubleshoot VS Code extension (#3510)
This adds a short blurb how to install the VS Code extension to the
troubleshooting guide.

Possible concerns:
- maybe redundant as there are already official VS Code Deno docs
- could be shortened to just refer to the main docs or completely
removed
2025-10-01 13:20:47 +02:00
fry69 89ae0935b6 docs: troubleshoot dependency installation (#3508)
This adds:
- a short blurb about missing dependencies to the troubleshooting guide
- a hint to this guide in the getting starting page
2025-09-30 11:32:37 +02:00
Bruno Bernardino fa6f4f4bef docs: fix wrong variable name in migration guide (#3496)
You have `export const handlers = ` when it needs to be `export const
handler = `.

I'm unsure if there's any build process I need to run for this.
2025-09-26 11:03:42 +02:00
fry69 f82bd7e63d docs: add deno.json update section to migration guide (#3471)
fix #3470 

This adds a short blurb about `deno.json` focusing on imports.

Background: Without `npm:vite` and `jsr:@fresh/plugin-vite` installed it
can lead to confusing errors like this one:
```shell
$ deno task dev
vite: command not found
```

Which might lead to users install Vite globally, which is not needed
(and will not fix this problem).
2025-09-20 13:17:11 +02:00
Mau Scheff 18961995d5 docs: Revise migration guide with new help sections (#3455)
Revise migration guide with new help sections
2025-09-16 13:24:39 +02:00
Marvin Hagemeister 3867e60664 fix: improve missing build cache error message (#3441)
Hoping that this helps folks who ignore the migration guide and keep the
entry pointed to `main.ts`.
2025-09-15 19:19:10 +02:00
fry69 999b89501e docs: fix testing docs (#3419)
This fixes the testing page in the docs for real this time.

Every test is hand checked now. Thanks to a certain button, which
appeared recently.

Optionally I can also split this page up in separate pages:
- Middlewars
- AppWrappers and Layouts
- Routing and Handlers
- SSR and Islands
2025-09-15 16:53:48 +00:00
fry69 016f94e28e docs: fix minor issues in middleware docs (#3436) 2025-09-15 12:20:48 +02:00
Emil KrebsandMarvin Hagemeister b4bb004753 feat: add CSP and header middleware (#3421)
Added a CSP and header middleware to simplify the HTTP Security Response
Header creation.

Fixes:
- https://github.com/denoland/fresh/issues/1705

Example:

```ts
// main.ts

export const app = new App<State>()
    .use(csp({
        reportTo: '/api/csp-reports',
    }))
    .use(headers({
        'Cross-Origin-Resource-Policy': 'same-site',
        'Cross-Origin-Embedder-Policy': 'require-corp',
        'Cross-Origin-Opener-Policy': 'same-origin',
        'Permissions-Policy':
            'geolocation=(), camera=(), microphone=(), payment=(), usb=(), bluetooth=(), magnetometer=(), gyroscope=(), accelerometer=()',
        'Referrer-Policy': 'strict-origin-when-cross-origin',
        'X-Content-Type-Options': 'nosniff',
        'X-Frame-Options': 'DENY',
        'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload',
    }))
```

Endpoint example:
```ts
// routes/api/csp-handler.ts

import { Context } from 'fresh';
import { State } from '../../main.ts';

export const handler = {
    async POST(ctx: Context<State>) {
        try {
            const text = await ctx.req.text();
            const body = JSON.parse(text);

            const logEntry = {
                timestamp: new Date().toISOString(),
                report: body,
                userAgent: ctx.req.headers.get('user-agent') || 'unknown',
            };
            await Deno.writeFile('csp-reports.log', new TextEncoder().encode(JSON.stringify(logEntry) + '\n'), { append: true });

            return new Response(JSON.stringify({ status: "ok" }), { status: 200 });
        } catch (error) {
            console.error("Error handling CSP report:", error);
            return new Response(JSON.stringify({ status: "error", error: String(error) }), { status: 500 });
        }
    },
};

```

Implementing these headers improved the security report at [Security
Headers](securityheaders.com) from F to A and helps to prevent security
vulnerabilities like Cross-Site Scripting and Clickjacking.

**Before**
<img width="1200" height="308" alt="image"
src="https://github.com/user-attachments/assets/01adfff4-5bb4-4cc6-bd8f-5e74b471301b"
/>
**After**
<img width="1200" height="335" alt="image"
src="https://github.com/user-attachments/assets/c5a9b07e-babf-4797-b47d-4368de70cbc3"
/>

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-09-15 12:20:22 +02:00
Zhi 7999d500f8 docs: fix missing files on "sharing state with islands" page (#3377)
close #3376
2025-09-12 17:16:30 +02:00
Marvin Hagemeister e06f03ac67 fix: add missing compile entry (#3410)
Fixes https://github.com/denoland/fresh/issues/3409
2025-09-12 13:08:49 +02:00