Skip to content

Simplify middleware - #33

Merged
jonatanklosko merged 1 commit into
mainfrom
jk-simplify
Oct 9, 2025
Merged

Simplify middleware#33
jonatanklosko merged 1 commit into
mainfrom
jk-simplify

Conversation

@jonatanklosko

Copy link
Copy Markdown
Contributor

See README changes for the simplified instructions.

In the request handler, we look at the original URL (from before middleware rewrite), therefore it doesn't really matter at which path the handler itself resides. This means:

  1. Instead of pages/api/tidewave/[...all].ts, we can have a simpler route pages/api/tidewave.ts and it works the same way. This file is slightly less annoying to create (compared to [...all]).

  2. The middleware can redirect to a fixed route in all cases, which streamlines the code.

I also added a check to make sure that if someone accesses /api/tidewave we show a message to clarify.

I don't see any downsides, WDYT?

@josevalim josevalim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. But if we use the app router we will need a separate approach, but I guess that’s fine.

@jonatanklosko
jonatanklosko merged commit 9896c5f into main Oct 9, 2025
4 checks passed
@jonatanklosko
jonatanklosko deleted the jk-simplify branch October 9, 2025 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants