How can I define a fallback route in Aurelia which is navigated to when the current URL does not match any of routes in the configuration?
According to the docs here you can use
config.mapUnknownRoutes('not-found');
which will redirect any unmapped routes to the not-found component.
Related
I have a delete action in Nuxt application. And after a successful delete I need to redirect the user to another page. But in Nuxt router documentation, there is no mention about redirecting. So the question is how to do it in component?
You can totally use either
<nuxt-link :to="{ name: 'my-fancy-route' }">Go to</nuxt-link>
or
this.$router.push({ name: 'my-fancy-route' })
Depending on what you're trying to achieve here.
Also, all of your routes can be found with the Vue devtools, go to Routing > Routes and you will be able to see them all there.
For more info, Nuxt is using vue-router behind the curtains, so a reference to this part of the documentation will be good: https://router.vuejs.org/guide/essentials/navigation.html#router-push-location-oncomplete-onabort
As mentioned, you can use this.$router.push(yourPath) to redirect the user. You should be able to use either the route name or explicit path in place of yourPath. If you're unsure of the route names generated by Nuxt, you can view them in .nuxt/routes.json.
Note that Nuxt uses Vue router so, for more detailed documentation, you might want to read this.
this.$router.push({
path: '/your-path',
});
I do not know the difference between using Router replace and route redirect
and how to use them in my project I am new in vue.js
The Documentation should give you all information necessary.
But to answer your question:
router.replace() replaces the current entry in the history stack, while route.redirect() actually redirects to another path, having both in the history stack.
a redirect will be triggered before any navigation guard and trigger a new navigation to the desired path.
I have a little problem with Swagger: I created a new action in my controller but when starting the web server I notice Swagger completely ignores the route of the controller. Instead of having "api/users/login" route, I just have "/login".
Screen from my code
You have specified the route as
[HttpPost("/login")]
It should be
[HttpPost("login")]
When you start the path with a slash, you override the parent route.
You can check my deep dive article for attribute routing for more info: https://joonasw.net/view/attribute-routing-cheat-sheet-for-aspnet-core
In one of my website in laravel. I facing error 419 when i called login api below my search web route
Route::get('/{address_1}/{address_2?}/{address_3?}/{address_4?}');
Route::post('/{address_1}/{address_2?}/{address_3?}/{address_4?}');
And Below Api Route
Route::post('login', 'Auth\PassportController#login');
Route::post('register', 'Auth\PassportController#register');
In Laravel, a 419 HTTP error code is usually a sign that you are missing a CSRF token.
If the 'API' routes:
Route::post('login', 'Auth\PassportController#login');
Route::post('register', 'Auth\PassportController#register');
Are in your web.php file then this is likely because the RouteServiceProvider wraps the routes in your web.php file inside the web middleware which has the CSRF middleware enabled.
If this is the case, you will either need to include a CSRF token in your POST request, move these routes to the api.php routes file, or add the register endpoint to the $excludes array of the VerifyCsrf middleware.
update
Actually, your search routes are going to cause a lot of grief.
Given the fact that they can match any URL with one to four segments, your API routes are getting swallowed by these.
What you will need to do is alter your RouteServiceProvider to register web routes last and then put your search routes last.
This way, your pre defined routes will be registered before your “catch-all” search routes.
I bootstrapped my application from webpack template and added the route /edit/:filename to it.
The problem is, filenames containing a dot are handled by Express and not by my Vue application.
In other words, /edit/123 is matched by the route but /edit/123.json or /edit/123.txt is not and I get a 404 from Express.
How can I match anything or at least /edit/anyfilename.json in my route?
I had an answer from Linus Borg on Vue forum. Vue webpack template uses connect-history-api-fallback to redirect all HTTP requests to index.html. It skips HTTP requests with a dot in the path unless disableDotRule is set to true. The proper config is
app.use(require('connect-history-api-fallback')({
disableDotRule: true,
rewrites: [
{from: /\/app.js/, to: '/app.js'}
]
}))
Notice that we have to add an extra rewrite to /app.js so that it is not redirected to index.html.