create-choo-app icon indicating copy to clipboard operation
create-choo-app copied to clipboard

404 handled weirdly

Open AdriVanHoudt opened this issue 6 years ago • 3 comments

So this is probably a thing with the router or something but I found this through the app generated by this lib so I thought I would start here ^^

My route config looks like

app.route('/', require('./views/main'))
app.route('/title', require('./views/title'))
app.route('/test/:id', require('./views/test'))
app.route('*', require('./views/404'))

after adding 1 test route (with nothing special in it, just prints out the state)

Now when I add a button that does a pushState to /test/4?a=4 that works great. Then I reload the current page and I get No route found for /test/1?a=4.

I tried some stuff and saw that choo passes a default /404 route for, well, 404's :P which isn't there. I would suspect it to go to * maybe but that doesn't seem the case.

Now when I add

app.route('/404', require('./views/404'))

Everything seems to work, reloading on the state actually loads the right view.

I'll be glad to look into this more or give you more info if you need it

AdriVanHoudt avatar Nov 09 '17 17:11 AdriVanHoudt

Hmmm, I'm guessing this is a failure of Server Side Rendering; probably missing to pick up a route in Bankai. What's your version of Bankai, Node, and NPM? Thanks a lot for raising this!

cc/ @flet didn't we publish a patch for this recently? I feel we there might perhaps still be a bug somewhere with the Server Render logic.

yoshuawuyts avatar Nov 10 '17 13:11 yoshuawuyts

Bankai: 9.0.0-rc9 Node: 8.9.0 npm: 5.5.1

Didn't even know it was doing ssr /mindblown :D

AdriVanHoudt avatar Nov 10 '17 13:11 AdriVanHoudt

Hello!

I just tried this out with create-choo-app (which is currently [email protected]) and it seems to be working ok?

I added this route to index.js: (Just above the 404 route)

app.route('/test/:id', require('./views/test'))

And I added this file views/test.js:

var html = require('choo/html')
module.exports = view

function view (state, emit) {
  return html`
    <body class="sans-serif">
      <p>
        Foo is ${state.params.id}
      </p><p>
        Bar is ${state.query.bar}
      </p>
    </body>
  `
}

Then npm start and navigate to https://localhost:8080/test/123?bar=1 and it works!

@AdriVanHoudt Could you update to rc10 and give it another try?

Flet avatar Nov 13 '17 16:11 Flet