Next.js Discord

Discord Forum

Getting params our of a rewrite

Unanswered
Cinnamon posted this in #help-forum
Open in Discord
CinnamonOP
Example: A person googles "watch the office on ExampleNetwork".

They see the links from google. They click one to come to my app.

This takes them to the following url http://localhost:3000/series/the-office_e4aae1234-6f3f-4448-9449-9844444cc9ed

Once they get to this url, the UUID is used to get all the data from the server.

Goal: I want the url to be http://localhost:3000/series/the-office/ for better SEO.

Problem: I am trying to use middle to get hold of the url, rewrite it for better seo performance, however I still need to make the network request and get the data.

What I have done so far (in pictures)
1. Created the middleware which intercepts the url and changes it to /series/test

Problem, the params are not there any more because I have removed them.

A few question I have is: how can I still make sure the id is there? Is there a way I can save it somehow to a cache and then get it for my component to use the in the network request?

2 Replies

CinnamonOP
@joulev
@Cinnamon <@484037068239142956>
Hmm. So which of my message is relevant to this that you need clarification on?