Skip to content
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

[4.x] Fix translations in nocache tag #9400

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Statamic\Http\Middleware\CP\AuthGuard as CPAuthGuard;
use Statamic\Statamic;
use Statamic\StaticCaching\NoCache\Controller as NoCacheController;
use Statamic\StaticCaching\NoCache\NoCacheLocalize;

Route::name('statamic.')->group(function () {
Route::group(['prefix' => config('statamic.routes.action')], function () {
Expand Down Expand Up @@ -45,6 +46,7 @@

Route::prefix(config('statamic.routes.action'))
->post('nocache', NoCacheController::class)
->middleware(NoCacheLocalize::class)
->withoutMiddleware('App\Http\Middleware\VerifyCsrfToken');

if (OAuth::enabled()) {
Expand Down
17 changes: 17 additions & 0 deletions src/StaticCaching/NoCache/NoCacheLocalize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Statamic\StaticCaching\NoCache;

use Closure;
use Statamic\Facades\Site;
use Statamic\Http\Middleware\Localize;

class NoCacheLocalize extends Localize
{
public function handle($request, Closure $next)
{
Site::resolveCurrentUrlUsing(fn () => $request->get('url'));

return parent::handle($request, $next);
}
}
Loading