Comments (13)
I think adding no-cache headers to the redirect fixed it.
Maybe this problem was here all along, but no one caught it yet... I don't know. :)
Give it a try in 2.6.2.
from laravel-localized-routes.
Hello,
That is indeed strange!
Does the same thing happen with all routes, like "/about" redirecting to "/nl/about"?
Or is it just the home route?
from laravel-localized-routes.
Just tried it with an /about
route as you suggested.
Route::get('about', function () {
return view('about');
});
Redirects happen as follows, in this order:
/about
→/en/about
(desirable/expected)/nl/about
→/nl/about
(desirable/expected; cookie/session locale now set tonl
)/about
→/en/about
(not desirable/expected)
Oddly, while /about
redirects to /en/about
, the homepage /
keeps redirecting to /nl/
. With use_localizer
enabled, the locale
cookie and session get set, but somehow forgotten or overridden by a default on a subsequent 'slugless' request.
from laravel-localized-routes.
Did you add the middleware to the $middlewarePriority
array in the Http/Kernel.php
?
Perhaps the middleware now runs before the session get activated or something...
from laravel-localized-routes.
I was wondering about that... My Http/Kernel.php
(Laravel 8.65) has no such array, only $middleware
, $middlewareGroups
, and $routeMiddleware
, so I added it to $middlewareGroups
.
from laravel-localized-routes.
Ah yes.
They moved it to the parent class, but in some cases you still need it.
When you want to use route model binding you will definitely need it too.
You can just copy it over and add the middleware between the sessions and bindings middleware.
Edit:
The priority array is always needed, but then you have a choice:
- add the middleware to the
$middlewareGroups
, the$middleware
array to apply the middleware to the group or to all routes - set the config option
use_locale_middleware
to true to apply the middleware to routes within theRoute::localized()
closure - apply the middleware in the routes file, per route or group
You should only use one of the 3 options.
from laravel-localized-routes.
Done! The problem persists, unfortunately.
Mind you, this is a clean Laravel installation. Getting localized routes was literally the first thing I did, so there's no conflicting middleware or other stuff going on.
from laravel-localized-routes.
Oh ok, can you put it somewhere so i can have look?
from laravel-localized-routes.
Sure Ivan, and thanks for your time and effort. You can find the brand new repo here :)
https://gitlab.com/ufomeldpunt/ufodb
from laravel-localized-routes.
I don't know what changed, but weird things are happening.
I created a fresh app myself too.
If you go to /en
or /nl
the locale is stored in the session and in a cookie.
The FIRST time you trigger a redirect, it takes the correct locale from the session/cookie.
But after that, even tho the session and cookie changes, the redirect is cached or remembered somehow...
Even if I comment out the redirect code, or do a dd()
it has no effect at all... It is still redirecting...
Also, each redirect is potentially cached for a different locale:
- Go to
/nl
- sets nl locale - Go to
/
- redirects to/nl
- Go to
/en
- sets en locale - Go to
/about
- redirects to/en/about
- Go to
/
- still redirects to/nl
Is Laravel caching the redirect response?
I'll have to investigate deeper.
from laravel-localized-routes.
Is Laravel caching the redirect response?
Seems so! I'll keep an eye on this issue. Hope you find some time to look into it. Thanks and stay safe!
from laravel-localized-routes.
That solved it! I had to clear Chrome's permanent redirect cache, but once that was done everything worked as expected. Thanks so much!
from laravel-localized-routes.
Great!
That was a brain breaker, yet such an easy fix :)
from laravel-localized-routes.
Related Issues (20)
- How to use with Laravel Route Attributes
- Redirect Issue with Octane HOT 3
- Call to undefined method Composer\Util\Platform::getCwd() HOT 5
- Advanced Scoped Options - Multi-site (domain localization & slug localization) HOT 7
- Scoped Options supported_locales overridden not working
- Fallback Controller Invalid Route Action HOT 4
- Authentication Breaks on Localized Routes HOT 5
- Route not defined. HOT 3
- * Use Localizer to Detect and Set the Locale HOT 1
- Resource routes HOT 2
- composer-include-files dependency breaks autoload-dev files HOT 3
- How to override route helper? HOT 4
- Share routes with front frameworks like Inertia/VueJS HOT 4
- What's the best way to deal with more complex locales like 'ch-fr'? HOT 1
- Subdomain localized urls HOT 6
- How to remove route parameters? HOT 5
- auto redirect HOT 5
- Redirect request with default locale to omitted locale url HOT 4
- Locale Switcher HOT 2
- Call to a member function getAction() on null HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-localized-routes.