question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rewrite next.config.js doesn't work

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

This setup just doesn’t work. I need to create a React /app to point to a react application that is still being migrated. but it just doesn’t work

async rewrites() {
    return {
      fallback: [
        {
          source: '/reactjs',
          destination: `https://reactjs-micro-frontend-base.vercel.app/reactjs`,
        },
        {
          source: '/reactjs/:path*',
          destination: `https://reactjs-micro-frontend-base.vercel.app/reactjs/:path*`,
        },
      ]
    }
  },

this configuration below works, but I lose my [slug].tsx from my main pages

async rewrites() {
    return {
      fallback: [
        {
          source: '/:path*',
          destination: `https://reactjs-micro-frontend-base.vercel.app/:path*`,
        },
      ]
    }
  },

I’m using nextjs to get id and slug params via mywebsite.com/SLUG and I need to use mywebsite.com/reactjs to point to my app in REACTJS.

I can’t create a redirect because it would lose the url mywebsite.com/reactjs.

I already bought the federation MF and SRR module, but it doesn’t solve my problem, because it only imports react components and not an entire application with routes, context and all the features that already exist in reactjs ready.

They are being migrated little by little.

The error it presents is that the reactjs source files were not found on mywebsite.com as they are in another path. the second setting returns reactjs app the first returns blank page

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Next.config.js configuration doesn’t work perfectly or there is no explanation for my problem.

Expected Behavior

Direct to application in reactjs according to the second configuration that works perfectly

Link to reproduction

I do not have

To Reproduce

Link to vercel application https://home-micro-frontend-base.vercel.app

Link Github configuration apps https://github.com/EmersonGarrido/micro-frontend-base

Link Github ReactJS APP https://github.com/EmersonGarrido/reactjs-base

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
balazsorban44commented, Aug 13, 2022

This issue has been automatically closed because it wasn’t verified against next@canary. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.

0reactions
github-actions[bot]commented, Oct 9, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rewrites - next.config.js
Rewrites allow you to map an incoming request path to a different destination path. Rewrites act as a URL proxy and mask the...
Read more >
Next.JS rewrite isn't happening - Stack Overflow
I am supposing at the moment that the rewrites never happen because these are supposed to be done on the serverside and maybe...
Read more >
Setup Next.js URL Rewrites with Netlify - Bits and Pieces
In Next.js, we can define URL rewrites in the next.config.js file. For example, the following code snippet shows how to write a simple ......
Read more >
next.config.js: Rewrites
rewrites is an async function that expects an array to be returned holding objects with source and destination properties:
Read more >
How to implement redirects in Next.js - LogRocket Blog
To test the redirect, open your browser and navigate to · again. You should now be automatically redirected to ; After restarting the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found