Coder Social home page Coder Social logo

404 on direct request to route about wouter HOT 6 CLOSED

molefrog avatar molefrog commented on April 30, 2024
404 on direct request to route

from wouter.

Comments (6)

eti0 avatar eti0 commented on April 30, 2024 3

just in case, for anyone that stumbles upon this same issue while using vercel.

simply add this to vercel.json :

"rewrites": [
    {
        "source": "(.*)",
        "destination": "/index.html"
    }
]

after that, you should be good to go :)

from wouter.

molefrog avatar molefrog commented on April 30, 2024

Well, it should work with any type of navigation, even those that are fired outside of a link. Can you provide an example?

from wouter.

talentlessguy avatar talentlessguy commented on April 30, 2024

Example is here: v1rtl.site

FIrst try to click on "Art", then "More stuff". It loads normally.

image

image

Now let's try to go to page directly.

image

Code of Router is here:

<Fragment>
    <Route path="/" exact component={Main} />
    <Route path="/art" component={Art} />
    <Route path="/gif" component={Gif} />
    <Route path="/web" component={Web} />
  </Fragment>

from wouter.

molefrog avatar molefrog commented on April 30, 2024

Well, that's because you have to tell Now.sh to serve your application's index.html on every request different from just /. That's the way routing in SPAs works, so the issue is not in wouter, but rather in your website deployment setup.

Not sure, but I think here is what might help:
https://zeit.co/docs/v2/advanced/configuration#routes

from wouter.

molefrog avatar molefrog commented on April 30, 2024

Oh, and by the way, no need to mark route as exact. A Route in wouter always matches an entire string.

from wouter.

talentlessguy avatar talentlessguy commented on April 30, 2024

Oh, and by the way, no need to mark route as exact. A Route in wouter always matches an entire string.

Oopsie, I just moved from React Router 😄, will remove exact. And yup, problem is with Now.sh, closing the issue. Sorry for interruption.

Oopsie x2, this now.json doesn't work but I'll better ask on Spectrum:

{
  "routes": [
    {
      "src": "*",
      "dest": "/index.html"
    }
  ]
}

from wouter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.