Skip to content

Client-Side Routing Broken in Latest Release #14993

@alexlafroscia

Description

@alexlafroscia

Description

Client-side routing does not seem to be supported any longer when serving the app in "production" (either through gatsby serve or some other static file serving). An unrecognized route redirects back to the route where the client-side router has been mounted.

Steps to reproduce

You can start with this repo here:

https://github.com/alexlafroscia/___gatsby-dynamic-routing-bug

Basically you

  • Generate a new Gatsby app
  • Configure Gatsby to treat all routes (/*) as being client-side
  • View the production version of the app

Expected result

I would expect that, if you hit something like the /foobarbax, it would render the client-side 404 page. This is actually working in local dev.

Index Page

Screen Shot 2019-06-20 at 3 18 42 PM

Client-Side 404 Page

Screen Shot 2019-06-20 at 3 18 46 PM

Actual result

In the fully static mode it redirects back to the root of the app instead of rendering my 404 component.

This was recorded when running gatsby serve in that repo

Kapture 2019-06-20 at 15 23 23

Even after changing the URL, it redirects back to the root of the app instead.

Environment

  System:
    OS: macOS 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Shell: 5.6.2 - /usr/local/bin/zsh
  Binaries:
    Node: 10.13.0 - /var/folders/nv/f8tyc7b960nf4kptb5890t400000gn/T/yarn--1561069776540-0.10964542529805676/node
    Yarn: 1.13.0 - /var/folders/nv/f8tyc7b960nf4kptb5890t400000gn/T/yarn--1561069776540-0.10964542529805676/yarn
    npm: 6.4.1 - ~/.asdf/installs/nodejs/10.13.0/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 64.0.2
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.10.0 => 2.10.0 
    gatsby-image: ^2.2.0 => 2.2.0 
    gatsby-plugin-create-client-paths: ^2.1.0 => 2.1.0 
    gatsby-plugin-manifest: ^2.2.0 => 2.2.0 
    gatsby-plugin-offline: ^2.2.0 => 2.2.0 
    gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0 
    gatsby-plugin-sharp: ^2.2.0 => 2.2.0 
    gatsby-source-filesystem: ^2.1.0 => 2.1.0 
    gatsby-transformer-sharp: ^2.2.0 => 2.2.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: confirmedIssue with steps to reproduce the bug that’s been verified by at least one reviewer.type: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions