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

react-dev-overlay does not work correctly with basePath #14470

Closed
OnurGvnc opened this issue Jun 22, 2020 · 2 comments · Fixed by #14475
Closed

react-dev-overlay does not work correctly with basePath #14470

OnurGvnc opened this issue Jun 22, 2020 · 2 comments · Fixed by #14475
Assignees
Milestone

Comments

@OnurGvnc
Copy link

OnurGvnc commented Jun 22, 2020

Bug report

Describe the bug

react-dev-overlay does not work as expected when it is run with basePath because it sends a request to the /__nextjs_original-stack-frame and /__nextjs_launch-editor paths. however, when basePath is active, requests get 404 error because these paths are not actually available.

if (pathname === '/__nextjs_original-stack-frame') {

} else if (pathname === '/__nextjs_launch-editor') {

.fetch(`/__nextjs_original-stack-frame?${params.toString()}`, {

self.fetch(`/__nextjs_launch-editor?${params.toString()}`).then(

self.fetch(`/__nextjs_launch-editor?${params.toString()}`).then(

To Reproduce

next.config.js

module.exports = {
  experimental: {
    basePath: '/blog',
  },
};

pages/index.js

export default function Index() {
  return (
    <div>
      <h1>Hi!</h1>
      {foo}
    </div>
  );
}

image

image

Expected behavior

image

System information

  • OS: macOS
  • Browser chrome
  • Version of Next.js: 9.4.4
  • Version of Node.js: 14.3.0

Additional context

I have resolved my problem temporarily by creating a custom server with the following method.

const express = require('express');
const next = require('next').default;
const port = parseInt(process.env.PORT, 10) || 3000;

const nextServer = next({
  dir: '.',
  dev: process.env.NODE_ENV !== 'production',
});

const handler = nextServer.getRequestHandler();
const app = express();

nextServer.prepare().then(() => {
  app.use((req, res) => {
    if (
      req.originalUrl.startsWith('/__nextjs_original-stack-frame') ||
      req.originalUrl.startsWith('/__nextjs_launch-editor')
    ) {
      req.url = '/blog' + req.originalUrl;
    }
    return handler(req, res);
  });
  app.listen(port, (err) => {
    if (err) {
      throw err;
    }
    console.log(`> Ready on port ${port} `);
  });
});
@kodiakhq kodiakhq bot closed this as completed in #14475 Jun 23, 2020
kodiakhq bot pushed a commit that referenced this issue Jun 23, 2020
This fixes the `basePath` not being used when making requests for the `react-dev-overlay`. We might want to pass down the `basePath` to the overlay instead of relying on the `process.env` injection although may be fine this way, will defer to @Timer for preferred way to pass this value to the dev-overlay

Closes: #14470
@Timer Timer added this to the iteration 3 milestone Jun 23, 2020
@ijjk
Copy link
Member

ijjk commented Jun 23, 2020

@OnurGvnc this should be resolved in the latest canary of Next.js v9.4.5-canary.18

rokinsky pushed a commit to rokinsky/next.js that referenced this issue Jul 11, 2020
This fixes the `basePath` not being used when making requests for the `react-dev-overlay`. We might want to pass down the `basePath` to the overlay instead of relying on the `process.env` injection although may be fine this way, will defer to @Timer for preferred way to pass this value to the dev-overlay

Closes: vercel#14470
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants