I am trying to deploy an application on a shared hosting (LWS). My app uses Laravel12 as a backend and Vuejs as frontend The frontend is installed directly on the domain.fr and the backend on a backend.domain.fr
The folder structure of the hosting is:
htdocs/ |--assets(dir) //for the frontend |--index.html //for frontend |--backend(dir) |--app(dir) |--bootstrap(dir) |--config(dir |--sanctum.php |--cors.php |-- (etc.) |--database(dir) |--public(dir) |--resources(dir) |--routes(dir) |--api.php |--auth.php |--web.php |--storage(dir) |--test(dir) |--vendor(dir) |--backend.denentzat.fr //the document root of the sub domain |--index.php |--.htaccess
The index.php file in backend.denentzat.fr (document root)
<?php
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../backend/storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../backend/vendor/autoload.php';
// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../backend/bootstrap/app.php')
->handleRequest(Request::capture());
The .htaccess file in backend.denentzat.fr
<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}]
# Handle X-XSRF-Token Header
RewriteCond %{HTTP:x-xsrf-token} .
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
# 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>
The relevant part of the .env in backend
APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:O4uiM3LM6/ryGhkGYSz9fdeRPznPIHGcJzSTvMeuBUM=
APP_DEBUG=true
APP_URL=https://backend.denentzat.fr
FRONTEND_URL=https://denentzat.fr
REGISTER_CODE=Amendeuix
SANCTUM_STATEFUL_DOMAINS=denentzat.fr
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=a db name
DB_USERNAME=a username
DB_PASSWORD=a password
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=.denentzat.fr
SESSION_SECURE_COOKIE=true
SESSION_HTTP_ONLY=true
SESSION_SAME_SITE=lax
The cors file in backend/config/
<?php
return [
'paths' => ['*'],
'allowed_methods' => ['*'],
'allowed_origins' => [env('FRONTEND_URL', 'http://localhost:9000')],
'allowed_origins_patterns' => ['*'],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
];
At the moment I make the test with an embryo of Laravel12 that permits only registering of a user (Créer un compte) or login (Se connecter) Everything works in dev.
In production, with this configuration the frontend works but all requests from the fe to
https://backend.denentzat.fr/sanctum/csrf-cookie
returns a 500 error. The body of the response is not available to the scripts (cause: CORS Missing Allow Origin)
To check further on, I also added a route to the file web.php in backend/routes/
Route::get('/test',function(){
return 'Everything is OK';
});
Visiting https://backend.denentzat.fr/test returns
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Here is an example of logs. The last time is in the case of visit to https://backend.denentzat.fr/test the other all comes 5 times with a single visit to the frontend
Date : 05/11/2025 09:53:14
IP : 83.193.34.84:0
Requête : GET /test HTTP/2.0
Code HTTP : 500
Referer : Aucun
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0
Erreur : AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Date : 05/11/2025 09:52:31
IP : 83.193.34.84:0
Requête : GET /sanctum/csrf-cookie HTTP/2.0
Code HTTP : 500
Referer : https://denentzat.fr/
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0
Erreur : AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Request exceeded the limit of 10 internal redirects- so there is a problem with your Apache config. It looks like the backend docroot is nested under the main site docroot? So maybe they are interfering, is there an.htaccessat the top level, or something else in the top level vhost config, which might be interfering with the backend? It would be simpler to keep the docroots separate, can you do that? Have you tried usingLogLevelas suggested to trace what is happening?