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

Client-side pages with path params fail on Windows #31791

Closed
bartosjiri opened this issue Jun 6, 2021 · 3 comments
Closed

Client-side pages with path params fail on Windows #31791

bartosjiri opened this issue Jun 6, 2021 · 3 comments
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@bartosjiri
Copy link

bartosjiri commented Jun 6, 2021

Description

Creating client-side pages with path match parameters fails on Windows because of invalid path characters (:):

Error: C:\Users\[redacted]\public\page-data\path\:param contains invalid WIN32 path characters.

Steps to reproduce:

  1. Create a client-side page configuration in the gatsby-node.js file:
    exports.createPages = async ({actions}) => {
      const {createPage} = actions
    
      createPage({
        path: '/path/:param',
        matchPath: '/path/:param',
        component: require.resolve('./src/templates/PageTemplate.js')
      })
    }
    
  2. Create a template for the given page in src/templates/PageTemplate.js:
    import React from 'react'
    
    const PageTemplate = ({param}) => (
      <h1>{param}</h1>
    )
    
    export default PageTemplate
    
  3. Run gatsby develop to build the project on a Windows machine.
  4. Visit http://localhost:8000/path/1 (if the process hasn't failed yet).

Expected result

  • Ability to visit http://localhost:8000/path/1 and see the provided parameter (1)

Actual result

(refer to issue description)

Environment

System:
  System:
    OS: Windows 10 10.0.19041        
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    gatsby: ^3.6.2 => 3.6.2 
  npmGlobalPackages:
    gatsby-cli: 3.6.0

References

@bartosjiri bartosjiri added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 6, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 6, 2021
@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jun 6, 2021

Hmm does this same bug occur if you make the route like src/pages/path/[id].js ?

https://www.gatsbyjs.com/docs/reference/routing/file-system-route-api/#creating-client-only-routes

@bartosjiri
Copy link
Author

Hmm does this same bug occur if you make the route like src/pages/path/[id].js ?

https://www.gatsbyjs.com/docs/reference/routing/file-system-route-api/#creating-client-only-routes

No, works perfectly, thank you @KyleAMathews!

@KyleAMathews
Copy link
Contributor

Ok good to know. The other way should work as well so we should fix it.

@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants