F
Filament12mo ago
Zetto

Deploying inside subdirectory

I am trying to deploy my app inside a site. The server team only gives me access docker instance at "example.com/exampleapp/" (so that's the root of the instance). I'm currently trying to solve the routing issue and asset registering. I see that the styles and scripts depends on the base url, but how can i change that? Currently the style and scripts are loaded from example.com/ . I'm looking for a way to change it to example.com/exampleapp/. Also i'm using nginx with the following site config
server {
listen 80;
server_name example.com;
root /var/www/exampleapp/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

location / {
try_files $uri $uri/ @exampleapp;
}

location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param REQUEST_URI /exampleapp$request_uri;
fastcgi_param SCRIPT_FILENAME /var/www/exampleapp/public/index.php;
include fastcgi_params;
}

location @exampleapp {
rewrite /(.*)$ /index.php?/$1 last;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~ /\.(?!well-known).* {
deny all;
}
}
server {
listen 80;
server_name example.com;
root /var/www/exampleapp/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

location / {
try_files $uri $uri/ @exampleapp;
}

location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param REQUEST_URI /exampleapp$request_uri;
fastcgi_param SCRIPT_FILENAME /var/www/exampleapp/public/index.php;
include fastcgi_params;
}

location @exampleapp {
rewrite /(.*)$ /index.php?/$1 last;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~ /\.(?!well-known).* {
deny all;
}
}
1 Reply
Zetto
ZettoOP12mo ago
Update: manage to get the js and script working using ASSET_URL inside .env and livewire setUpdateRoute and setScriptRoute. The only problem left is the route, while it is accessible and works fine, anything using route() is wrong. It points to the example.com/app instead of example.com/app On further inspection it's from Filament::getUrl() . Is there a way i can prefix all url inside my application?
Want results from more Discord servers?
Add your server