Skip to content

Bug: server.proxy not working with @fresh/plugin-vite #3814

Description

@Hajime-san

Step to Reproduce

  • deno.json
{
  "imports": {
    "vite": "npm:vite@7.1.11",
    "preact": "npm:preact@10.29.1",
    "fresh": "jsr:@fresh/core@2.3.3",
    "@fresh/plugin-vite": "jsr:@fresh/plugin-vite@1.1.2"
  },
  "nodeModulesDir": "auto",
  "compilerOptions": {
    "jsx": "precompile",
    "jsxImportSource": "preact",
    "jsxImportSourceTypes": "preact"
  },
  "tasks": {
    "start": "deno task proxy & deno task dev",
    "dev": "deno run -REWS --allow-run --allow-ffi --allow-net=127.0.0.1:3000,jsr.io:443 vite --host 127.0.0.1 --port 3000",
    "proxy": "deno run --allow-net=127.0.0.1:8000 proxy.ts"
  }
}
  • vite.config.ts
import { defineConfig } from 'vite';
import { fresh } from '@fresh/plugin-vite';

export default defineConfig({
  plugins: [fresh()],
  server: {
    host: '127.0.0.1',
    port: 3000,
    proxy: {
      '/api': 'http://127.0.0.1:8000',
    },
  },
});
  • main.ts
import { App } from 'fresh';

export const app = new App()
  .get('/', () => new Response('ok'));
  • proxy.ts
Deno.serve({ hostname: '127.0.0.1', port: 8000 }, (req) => {
  const url = new URL(req.url);
  console.log(`proxy ${req.method} ${url.pathname}${url.search}`);
  return Response.json({
    ok: true,
    pathname: url.pathname,
    search: url.search,
  });
});

Expected behaviour

% curl -i 'http://127.0.0.1:3000/api/ping?x=1'
HTTP/1.1 200 OK
content-type: application/json
content-length: 50
date: Fri, 22 May 2026 14:44:50 GMT

{"ok":true,"pathname":"/api/ping","search":"?x=1"}%

Acutual behaviour

% curl -i 'http://127.0.0.1:3000/api/ping?x=1'
HTTP/1.1 404
Vary: Origin
content-type: text/plain;charset=UTF-8
Date: Fri, 22 May 2026 14:41:30 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions