Closed 01binary closed 7 years ago
Hello,
This is probably an issue with misunderstanding how koa/koa-hbs work, but it may be useful for others when they have the same problem while learning.
TL;DR: instead of rendering my template, I get a 404 even though my route executes, see https://github.com/01binary/shopper/tree/HandlebarsInitial for a snapshot.
yarn build
hbs.middleware({ viewPath: path.resolve(__dirname, '../../dist'), extname: '.html' })
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>App</title> </head> <body> <div id="app"> {{mount}} </div> <script type="text/javascript" src="scripts/vendor.js?83f7fa2dc8d8f8322d36"></script><script type="text/javascript" src="scripts/app.js?83f7fa2dc8d8f8322d36"></script></body> </html>
route.get('/', async(context) => { console.log('about to render layout') await context.render('layout', { mount: render() }); })
When I navigate to my app, I see "about to render layout" logged out, but then it gets a 404:
<-- GET / about to render layout --> GET / 404 9,964ms -
Why doesn't the hbs middleare render? Does it send a 404 or does koa send a 404? I can't understand what's happening and how to debug it.
Thank you!
OK, inattentive readme reading on my part. I switched to using "next" version of koa-hbs:
readme
"dependencies": { "koa": "^2.3.0", "koa-hbs": "next", },
😄
Hello,
This is probably an issue with misunderstanding how koa/koa-hbs work, but it may be useful for others when they have the same problem while learning.
TL;DR: instead of rendering my template, I get a 404 even though my route executes, see https://github.com/01binary/shopper/tree/HandlebarsInitial for a snapshot.
yarn build
):When I navigate to my app, I see "about to render layout" logged out, but then it gets a 404:
Why doesn't the hbs middleare render? Does it send a 404 or does koa send a 404? I can't understand what's happening and how to debug it.
Thank you!