I am trying to achieve routes like http:mydomain.com/@username or http:mydomain.com/#username using flowrouter.
my route structure currently comprises public and private routes with some public routes like http:mydomain.com/about us, http:mydomain.com/contact us etc.
How do I implement http:mydomain.com/@username or http:mydomain.com/#username using flowrouter as public routes by catching routes with @ and #.
please share if you have implemented something similar or have a way of achieving my goal.
You’ll likely just need to use a url parameter in your route definition. You’ll want to define all your other routes first though so that your other routes match first and don’t try to load a users profile instead.
// define no user profile routes
FlowRouter.route('/dashboard', {
// options
});
FlowRouter.route('/admin', {
// options
});
//define profile route last so we don't try to load a profile for
//a user named admin or dashboard
FlowRouter.route('/:username', {
// options
});
You will also want to think about limiting usernames from already defined routes and you’ll need to make certain that a user hasn’t already taken the name of a route if you ever need to add new routes. It’s a small chance but it’s there.
Thank you for replying.
My challenge is that the admin and dashboard routes are not structurally different from the username routes.
That’s why I wanted to add the @ and # symbol so that those particular routes are differentiated and I can have custom core that runs only if such routes are entered.
For now I have, a structure below which achieves the differentiation and allows me run the custom code.