-
-
Notifications
You must be signed in to change notification settings - Fork 515
Open
Description
Add in web.php
Livewire::setUpdateRoute(function ($handle) {
return Route::post('/livewire/update', $handle);
});
in your app.blade
<script>
(function() {
const originalFetch = window.fetch;
const originalXHROpen = XMLHttpRequest.prototype.open;
const originalXHRSend = XMLHttpRequest.prototype.send;
@php
$locale = request()->segment(1);
$supportedLocales = array_keys(config('app.supported_locales', []));
$shouldAddLocale = in_array($locale, $supportedLocales);
@endphp
@if($shouldAddLocale)
const currentLocale = '{{ $locale }}';
window.fetch = function(url, options) {
if (typeof url === 'string' && url.includes('/livewire/update')) {
url = url.replace('/livewire/update', `/${currentLocale}/livewire/update`);
}
return originalFetch.call(this, url, options);
};
XMLHttpRequest.prototype.open = function(method, url, ...args) {
if (typeof url === 'string' && url.includes('/livewire/update')) {
url = url.replace('/livewire/update', `/${currentLocale}/livewire/update`);
}
return originalXHROpen.call(this, method, url, ...args);
};
@endif
})();
</script>
elrosi
Metadata
Metadata
Assignees
Labels
No labels