Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Disable default 404 page #31

Closed
abranhe opened this issue Jan 20, 2019 · 2 comments
Closed

Disable default 404 page #31

abranhe opened this issue Jan 20, 2019 · 2 comments

Comments

@abranhe
Copy link

abranhe commented Jan 20, 2019

About me

  • My name: Abraham
  • I've used Netlify: a lot

Question

I am creating a simple react application, basically it will match the pathname (/some/pathname) of the website and I will do something with it:

Example:
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

const Default = () => (<div>Home</div>);
const Test = () => (<div>Test</div>);
const NoMatch = () => (<div>404</div>);;

class App extends Component {
  render() {
    return (
        <Router>
        <Switch>
            <Route path="/" exact component={Default}/>
            <Route path="/test" component={Test}/>
            <Route component={NoMatch} />
      	</Switch>
        </Router>
    );
  }
}

It works perfectly locally, but when I deploy it to Netlify, every time I go to certain path /test, Netlify will detect it as a 404 code so it will display the famous 404 page.

404 page

I went over the documentation but I did't found anything to fit my needs.

Any ideas how could I accomplish it?

@j-f1
Copy link
Contributor

j-f1 commented Jan 20, 2019

Is the “HISTORY PUSHSTATE AND SINGLE PAGE APPS” section on that page what you’re looking for?

@abranhe
Copy link
Author

abranhe commented Jan 20, 2019

The NoMatch route should match any page, it is basically handling any pathname or 404 page.

@abranhe abranhe closed this as completed Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants