Skip to content

fix: override headers within req.rewrite() #2189

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

Merged
merged 3 commits into from
Jun 28, 2023
Merged

Conversation

taty2010
Copy link
Contributor

@taty2010 taty2010 commented Jun 26, 2023

Description

Based on the description provided here this update makes it to where we can now override the headers within the req.rewrite() like in the example below.

    const res = await request.rewrite('/static-rewrite',
    {
      headers: {
        'x-rewrite-test': 'hello',
        'x-rewrite-test-2': 'hello-2'
      }
    })

Documentation

Tests

You can test this change yourself like so:

  1. Go to https://deploy-preview-2189--next-plugin-edge-middleware.netlify.app/request-rewrite
  2. review the headers within the Network tab and should see the headers from the example code above.

Relevant links (GitHub issues, etc.) or a picture of cute animal

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/649c493ed733f60008d141d4
😎 Deploy Preview https://deploy-preview-2189--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/649c493e29cfc20007456c28
😎 Deploy Preview https://deploy-preview-2189--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/649c493e993df90008e7b081
😎 Deploy Preview https://deploy-preview-2189--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Jun 26, 2023
@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/649c493e486bd0000720509e
😎 Deploy Preview https://deploy-preview-2189--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/649c493e42287d0008ec16f8
😎 Deploy Preview https://deploy-preview-2189--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/649c493fac8601000858e109
😎 Deploy Preview https://deploy-preview-2189--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/649c493e5ecc340008e4082a
😎 Deploy Preview https://deploy-preview-2189--next-plugin-canary.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/649c493eac8601000858e104
😎 Deploy Preview https://deploy-preview-2189--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit a0bbac6
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/649c493eb412580008d9601a
😎 Deploy Preview https://deploy-preview-2189--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@taty2010 taty2010 changed the title fix: override headers/status within req.rewrite() fix: override headers within req.rewrite() Jun 28, 2023
@taty2010 taty2010 marked this pull request as ready for review June 28, 2023 14:05
@taty2010 taty2010 requested a review from a team as a code owner June 28, 2023 14:05
Copy link
Contributor

@MarcL MarcL left a comment

Choose a reason for hiding this comment

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

Think it just needs the test to be enabled and good to go.

Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

Looks good! 🚢

Copy link
Contributor

@MarcL MarcL left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Looks great. :shipit:

@kodiakhq kodiakhq bot merged commit cc8546e into main Jun 28, 2023
@kodiakhq kodiakhq bot deleted the tn-advMiddlewareRewriteInit branch June 28, 2023 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants