How to support routes with and without locale prefix in Fresh 2 without duplicating files?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- deno, typescript
- Domain
- backend
Research direction
The issue describes middleware behavior but names no source files, tests, or implementation entry points. Start by reading Fresh 2 middleware and route resolution documentation or code, then trace how ctx.next() selects a route for a prefixed URL. Done means establishing the recommended way to serve both URL forms from one route file, or identifying the framework change needed to support rewriting.
Written by the indexing model from the issue text.
Description
Discussed in https://github.com/denoland/fresh/discussions/3501
Originally posted by s00d September 27, 2025
Hi!
I’m trying to implement i18n in Fresh 2.
The goal is to support URLs both with locale prefix and without it, e.g.:
/aaa/de/aaa/ru/blog/some-post
I want both variants to resolve to the same route file (e.g. routes/aaa.tsx or routes/blog/[slug].tsx) without duplicating files under each locale folder.
I tried using middleware:
- It correctly detects the locale from the first URL segment.
- But
ctx.next()still resolves against the original URL (/de/aaa) → Fresh looks forroutes/de/aaa.tsx(which doesn’t exist) → 404. - Fresh doesn’t allow passing a modified
Requesttoctx.next(), so I cannot “rewrite” the path like in Next.js.
Questions:
- Is there an official / recommended way in Fresh 2 to handle this use case?
- Does the team plan to support some form of URL rewriting in middleware (so
/de/aaacan transparently resolve toroutes/aaa.tsx)?
Thanks in advance!
- Dominant language
- TypeScript
- Stars
- 13.8k
- Forks
- 757
- Avg merge
- 3m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from freshframework/fresh
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
freshframework/fresh#3920 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
freshframework/fresh#3833 ·
-
feat
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
freshframework/fresh#3803 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
freshframework/fresh#3918 · 1 comment · 4 reactions ·
-
Tab title doesn't update to <Head> <title> when navigating to a page with another <title>Possibly taken @1AbdullahButt claimed this 7 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 57/100
freshframework/fresh#3916 ·
All issues in freshframework/fresh
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tintinweb/pi-subagents#459 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
danielmiessler/LifeOS#2830 ·
Maintainers usually reply within 6 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: client enhancement priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
opensro-dev/opensro#3681 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day