I am trying to build an app using Laravel with Jetstream and Inertia + Vue.js.
URL looks like this : https://website/app/route
When I first visit the page, it loads and the URL changes to this : https://website/app/app/route. The page displays its content correctly.
If I reload, I have a 404 message. I have to remove one "/app" to display the content the right way again.
If I don't reload, I can navigate on the page whithout any problem.
Anyone has an idea ?
.htaccess :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I tried removing /app from APP_URL and ASSET_URL but no change occurs
APP_URL=https://website/app
ASSET_URL=https://website/app
answer is what follows :
in vendor/inertiajs/src/Response.php in toResponse() method the URL is built this way:
$page = [
'component' => $this->component,
'props' => $props,
'url' => $request->getBaseUrl().$request->getRequestUri(),
'version' => $this->version,
];
I overrided this file and changed it to :
$page = [
'component' => $this->component,
'props' => $props,
'url' => $request->getRequestUri(),
'version' => $this->version,
];