Skip to content

App.fsRoute & App.mountApp do not actually mount to the pattern they are provided #3566

@jacques-toquard

Description

@jacques-toquard

Fresh v2.1.2
Deno v2.5.3
Vite v7.1.10

I was trying to grasp Fresh and its concepts, and documentation, tinkering with the template provided by deno run -Ar jsr:@fresh/init
When I came across issues for both App.fsRoute() and App.mountApp().

According to the documentation for app.fsRoutes, ts modules for the Fresh 2./routes/ the pages returned by the previously mentioned template should be served at http://localhost/my-mount-path if the endpoints do not have any routeOverride (and they do not, they are still served at root).

import { App, cors, staticFiles, trailingSlashes } from "fresh";
import { define, type State } from "./utils.ts";
export const app = new App<State>();
app.use(
  staticFiles(),
  trailingSlashes("never"),
);
app.fsRoutes("/my-mount-path");

Same behavior arises from App.mountApp documentation:

These two snippets serve the pages served from ./routes/ at root too .

import { App, cors, staticFiles, trailingSlashes } from "fresh";
import { define, type State } from "./utils.ts";
export const app = new App<State>();
app.use(
  staticFiles(),
  trailingSlashes("never"),
);
const fsApp = new App<State>().fsRoutes("/my-second-mount-path");
app.mountApp("/", fsApp);
import { App, cors, staticFiles, trailingSlashes } from "fresh";
import { define, type State } from "./utils.ts";
export const app = new App<State>();
app.use(
  staticFiles(),
  trailingSlashes("never"),
);
const fsApp = new App<State>().fsRoutes("/my-second-mount-path");
app.mountApp("/my-mount-path", fsApp);
// Expected behavior: served at http://localhost/my-mount-path/my-second-mount-path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions