-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle routing (add more pages) #9
Comments
IMO, you should handle routing in Tailor. You can have your component fragment servers running, and you can create a template for each route of yours and expose them through Tailor. This gives you flexibility to change fragments on the fly without having to redeploy or change code. In order to do that, just change the current 'use strict'
const http = require('http')
const Tailor = require('node-tailor')
const tailor = new Tailor({
templatesPath: __dirname + '/templates'
})
http
.createServer((req, res) => {
if (req.url === '/favicon.ico') {
res.writeHead(200, { 'Content-Type': 'image/x-icon' })
return res.end('')
}
req.headers['x-request-uri'] = req.url
- req.url = '/index'
+ if (req.url === '/') {
+ req.url = '/index'
+ }
tailor.requestHandler(req, res)
})
.listen(8080, function() {
console.log('Tailor server listening on port 8080')
}) (someone please submit a pull request) Now you can have different templates in the templates folder, one for each route. When the route is |
Well, it happened that I just found some edge cases too. For example, let's say I have an application with a Dashboard. There is a In this dashboard, there is a menu list of sections in the dashboard you can access. If I don't care about SSR or URL Sharing, it is just fine to use smth like But if I do, I need to include I can also decouple my In this way, I might not need |
I'm still touching the surface about this whole micro frontend and Tailor thing. But i'm curious on how to handle additional routes / pages with this approach?
FYI, I'm just trying to start a discussion. Does not necessarily need a solution.
The text was updated successfully, but these errors were encountered: