Laramin answers Bad Request, redirects endlessly or loads without styles
Every page answers with error 400, the browser reports too many redirects, or the admin loads blank or unstyled. Fix the site address, proxy and HTTPS settings on the server.
- Applies to
- Core 12.7 and later
- Who can do this
- Platform owner
On this page
Symptom
One of these, usually right after installing, going live or moving Laramin:
-
Every address answers with a short error 400 (Bad Request) page that gives no reason.
-
The browser says the page redirects too many times, often just after Enable Force HTTPS on Extra Utilities.
-
The admin loads without styles or stays blank, and the browser's console shows blocked
http://orhttps://files.
All the fixes are in the server's settings file. After each change, whoever runs the server runs php artisan config:clear. To find the file, see A setting or a change to the settings file doesn't take effect.
Check these, in order
1. The address you open isn't the site address
Unless your Laramin runs in the local environment, it answers only addresses it trusts: the host in APP_URL and its subdomains, plus any host listed in TRUSTED_HOSTS. Every other address gets the error 400. It isn't written to the normal log; it's noted in the security log.
From Core 12.8.2, the web installer writes the address it was opened at into APP_URL. If you installed at an IP address or a temporary address, the real domain isn't trusted until you change it.
Fix: set APP_URL to the address people use, and list any other addresses in TRUSTED_HOSTS, separated by commas. Prefix an entry with *. to trust its subdomains too.
Couldn't copy. Select the code and press Ctrl+C (⌘+C on a Mac).
APP_URL=https://crm.example.com
TRUSTED_HOSTS=www.crm.example.com,*.example.comReplace the highlighted values with your own.
This command shows the trusted addresses and tests the one you give it:
Couldn't copy. Select the code and press Ctrl+C (⌘+C on a Mac).
php artisan security:hosts crm.example.comIf your Laramin was installed with Core 12.8.1 or earlier
The web installer left APP_URL at http://127.0.0.1:8000. If it still says that, set it to your site's address as above. Upgrading doesn't change it for you.
2. A proxy, load balancer or CDN that Laramin doesn't trust
Behind one of these, Laramin thinks every request arrives over plain HTTP. Force HTTPS then redirects for ever, and pages link to http:// files that the browser blocks.
Fix: set TRUSTED_PROXIES to the proxy's addresses, for example TRUSTED_PROXIES=10.. Your hosting provider can tell you its address ranges.
3. The environment is production or staging, and HTTPS doesn't work yet
In the production and staging environments, Laramin makes every link it creates start with https://, except for requests from the server itself. Without a working certificate, those links fail.
Fix: install the SSL certificate first, or keep the environment at local until it works.
4. Force HTTPS is on, and HTTPS doesn't work
You turned on Enable Force HTTPS on Extra Utilities, and now every page redirects to an address that doesn't load, so you can't reach Extra Utilities to turn it off. Force HTTPS is saved in Laramin's database, so the settings file can't turn it off.
Fix: whoever runs the server turns it off in the database, then clears the cache:
Couldn't copy. Select the code and press Ctrl+C (⌘+C on a Mac).
UPDATE general_settings SET value = 'false' WHERE module = 'core' AND name = 'force_https';Couldn't copy. Select the code and press Ctrl+C (⌘+C on a Mac).
php artisan cache:clearBrowsers that already visited the site may keep going to HTTPS for a while. Try a private window, or clear the site's data in the browser. Turn Force HTTPS on again only once the certificate works.
5. ASSET_URL names another address
When the admin loads without styles, the page's files may come from ASSET_URL. If that names an old address, or http://127.0.0.1:8000, the browser can't load them.
Fix: set ASSET_URL to your site's address, or remove the line.
From Core 12.8.2, the web installer also updates ASSET_URL and LOCAL_ASSET_URL when they were built on the template address. A value that names a CDN is left alone.
Still not working?
Raise a ticket from Support Center in your Laramin app. Include this page's link, the address you open, your environment name, whether a proxy or CDN sits in front of the server, and the output of php artisan security:hosts.
Thanks. That helps us decide what to write next.
Thanks for telling us what was missing.
You already answered for this article today. Thanks.
We got a lot of answers from your network just now. Try again in a few minutes.
We couldn't send that. Check your connection and try again.
Links in this article
Printed from help.bsscn.com. The online article may have changed since.