Route rewrite & localizated routes

Open
#3,811 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript
Domain
backend

Research direction

Start by reading Fresh's request handling and file based routing entry points to see where a request can be rewritten before route matching. The issue does not name specific files or tests, so first trace that flow and check how request context state is exposed. Done means a request can be rewritten before routing and its language stored in context for localized routes.

Written by the indexing model from the issue text.

Description

Hello,

I do really like Fresh!

However, I am missing some control on the routing.
For instance, I would like to make a framework for localized routing (for instance: /mon-nom/maurice (FR -> french page) and /my-name/maurice (EN -> english page).

To make such a system possible, I need to be able to rewrite a request before it passes through the file based routing. Then I could for instance set the language on the ctx.state object and rewrite the URL/route to the folder structure (which will be English always).

This way, localization is easier. This is also how frameworks like Paraglide are working with localized routes.

Is this possible, if not, could it be made possible?
Would be great!

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from freshframework/fresh

All issues in freshframework/fresh

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.