Reputation: 21
I'm in the process of hosting a full stack app. For the frontend I'm using Next JS for the frontend and for the backend Laravel with filament as a dashboard.
I tried to host everything on Digital Oceans App Platform where I gave the frontend the normal base route and the laravel backend the /app route.
To let Laravel know that the URL changed I set the the environment variable to:
APP_URL=${APP_URL}/app
The problem is now that when I try to log into my backend (example-site/app/admin/login) that I get an 404 for the CSS files and the login is not working.
Filament seems to be completely unaware that the URL changed. It's not only the CSS, but it also tries to redirect me to the base url when I click a button.
How do I let Filament know that the URL changed? Right now I'm thinking about moving the laravel app to the root folder and hosting the frontend on vercel.
Upvotes: 0
Views: 1152
Reputation: 123
I was experiencing this issue "livewire.js - 404 not found" too ... on the NGINX server. The same app worked fine in an apache2 environment.
What is happening with livewire (unless the assets are published and actually exist on the server, so nginx can serve them) is that the livewire.js file is build/served by the laravel app ... this means PHP. But in the default nginx server configuration, the request never gets that far, nginx just does not find the static js file and returns the 404 ... never passing the request to the laravel app.
There are 2 solutions to fix this issue:
1.) publish the livewire.js file any other static file, so nginx can return them.
2.) Add one line of code to the nginx config to tell nginx to check if the static file can be found on the disk/cache if not send the request to php-fpm (in our case the index.php file) so it can be built dynamically.
Here is the code ... usually you may already have a directive in your nginx config that tells nginx what to do with static files ... just add this line within the directive:
try_files $uri /index.php?$query_string;
So a complete directive added to the nginx server config may look like this:
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
try_files $uri /index.php?$query_string;
access_log off;
log_not_found off;
expires 14d;
}
if you only want this behavior for js files create a new directive and get js off the list in the previous example.
Upvotes: 1
Reputation: 11
In AppServiceProvider boot()
if (app()->isProduction()) {
\URL::forceScheme('https');
}
Upvotes: 1