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.

[Bug] Siteroot and basePath don't work with routes

See original GitHub issue

Environment

  • System: OS: macOS Mojave 10.14.3 CPU: (8) x64 Intel® Core™ i7-4870HQ CPU @ 2.50GHz Memory: 2.77 GB / 16.00 GB Shell: 3.2.57 - /bin/bash
  • Binaries: Node: 11.12.0 - /usr/local/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn
  • Browsers: Chrome: 73.0.3683.103
  • npmPackages: react: ^16.8.2 => 16.8.6 react-color: ^2.17.0 => 2.17.0 react-dom: ^16.8.2 => 16.8.6 react-static: ^7.0.0 => 7.0.5 react-static-plugin-reach-router: ^7.0.0 => 7.0.0 react-static-plugin-sitemap: ^7.0.0 => 7.0.0 react-static-plugin-source-filesystem: ^7.0.0 => 7.0.0 npmGlobalPackages: react-static: 7.0.7

Steps to Reproduce the problem

  • react-static create

with “basic” template

  • In static.config.js
import path from "path";

export default {
  siteRoot: "http://localhost:3000",
  basePath: "dist",
  // maxThreads: 1, // Remove this when you start doing any static generation
  plugins: [
    [
      require.resolve("react-static-plugin-source-filesystem"),
      {
        location: path.resolve("src/pages")
      }
    ],
    require.resolve("react-static-plugin-reach-router"),
    require.resolve("react-static-plugin-sitemap")
  ]
};

Expected Behavior

Template example should work normally with its routes

Problem

It doesn’t, console show 404 error for loading ressources, path is incorrect.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
gbrsalescommented, Jun 4, 2019

I proposed a fix in PR #1196.

1reaction
Vinnlcommented, Apr 24, 2019

Same here, can be seen on a live site here.

Console output of failed requests:

image

Links appear to point to the correct page, but then error out when clicked.

And indeed, the template tags appear wrong:

image

My debugging info:

$ npx envinfo --system --npmPackages react* --binaries --npmGlobalPackages react* --browsers
  System:
    OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    Memory: 555.84 MB / 7.52 GB
    Container: Yes
    Shell: 5.4.2 - /bin/zsh
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    Yarn: 1.15.2 - /usr/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
  Browsers:
    Chrome: 74.0.3729.108
    Firefox: 66.0.3
  npmPackages:
    react: ^16.8.6 => 16.8.6 
    react-dom: ^16.8.6 => 16.8.6 
    react-ga-donottrack: ^1.0.0 => 1.0.0 
    react-hot-loader: ^4.8.4 => 4.8.4 
    react-markdown: ^4.0.8 => 4.0.8 
    react-static: ^7.0.9 => 7.0.9 
    react-static-plugin-sass: ^7.0.8 => 7.0.8 
    react-static-plugin-typescript: ^7.0.8 => 7.0.8 
    react-syntax-highlighter: ^10.2.1 => 10.2.1 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Rewrites bug when using with basePath and public directory
Bug report Describe the bug Next.js cannot rewrites URL when using ... request not having basePath as its path prefix for public routes....
Read more >
Next.js app in subfolder with basePath, how to make home ...
but got an error: The route / rewrites urls outside of the basePath. Please use a destination that starts with `http://` or `https://`...
Read more >
Relative and absolute paths, in the file system and on the web ...
If you don't supply the root, it means that your path is relative. ... just build it from the site root - and...
Read more >
Router tutorial: tour of heroes - Angular
In this tutorial, you build upon a basic router configuration to explore features such as child routes, route parameters, lazy load NgModules, guard...
Read more >
Routes and Endpoints | REST API Handbook
The “route” is wp/v2/posts/123 – The route doesn't include wp-json because wp-json is the base path for the API itself. This route has...
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