Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite #8660

Closed
jamesli2021 opened this issue Jun 25, 2024 · 5 comments · Fixed by withastro/astro#11349
Closed

Rewrite #8660

jamesli2021 opened this issue Jun 25, 2024 · 5 comments · Fixed by withastro/astro#11349
Labels
improve documentation Enhance existing documentation (e.g. add an example, improve description) should this be documented? Need to figure out whether this is something to add to documentation or not

Comments

@jamesli2021
Copy link
Contributor

📚 Subject area/topic

Astro

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/reference/configuration-reference/#experimentalrewriting

📋 Description of content that is out-of-date or incorrect

According to the docs, rewrite is out of experimental.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

NA

@jamesli2021 jamesli2021 added the improve documentation Enhance existing documentation (e.g. add an example, improve description) label Jun 25, 2024
@sarah11918
Copy link
Member

Hi! Can you let me know where you saw docs say this is out of experimental?

This feature is indeed still experimental, and the entry on the configuration reference page is correct! If there's somewhere else it we say it is NOT, then that's incorrect and should be fixed!

@sarah11918 sarah11918 added the should this be documented? Need to figure out whether this is something to add to documentation or not label Jun 26, 2024
@jamesli2021
Copy link
Contributor Author

@sarah11918 I'm a bit confused, my rewrite work and I did not set experimental.

@ematipico
Copy link
Member

@sarah11918 I'm a bit confused, my rewrite work and I did not set experimental.

I probably forgot to add some warnings in the source code. I will take it from here. The feature is experimental, but I missed some checks. Thank you for flagging this.

@jamesli2021
Copy link
Contributor Author

jamesli2021 commented Jun 26, 2024

@sarah11918 I believe the blog shown an incorrect code as well?

https://astro.build/blog/astro-4100/#rewrite-for-all-http-methods

Is next('/next/v2') is the right API?

export const onRequest = defineMiddleware(({ request, url }, next) => {
  if(request.method === 'POST' && url.pathname === '/api') {
    return next('/api/v2');
  }
});

@ematipico
Copy link
Member

It's one of the new APIs. The others are Astro.rewrite and context.rewrite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve documentation Enhance existing documentation (e.g. add an example, improve description) should this be documented? Need to figure out whether this is something to add to documentation or not
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants