insecure XHR mixed content CORS error #11216
Replies: 3 comments 2 replies
-
|
If you're using a proxy, you'll need to configure "trusted proxies" in order for the HTTPS stuff to work properly: https://laravel.com/docs/master/requests#configuring-trusted-proxies |
Beta Was this translation helpful? Give feedback.
-
|
It appears I have resolved this by forcing HTTPS in Laravel. AppServiceProvider.php public function boot(): void
{
if(env('FORCE_HTTPS',false)===true) {
URL::forceScheme('https');
}
}.env |
Beta Was this translation helpful? Give feedback.
-
|
I've also run into this issue and fixed it by forcing HTTPS as @clifmo described above. I'm running into the issue on Fly.io, so I might have misunderstood how to bypass proxies using <?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
# Allow Fly as a proxy to use HTTPS and avoid mixed content browser errors
# This currently does not work, and I'm not sure why. HTTPS is being forced in
# AppServiceProvider.php using the FORCE_HTTPS environment variable, instead.
# https://github.com/statamic/cms/discussions/11216
$middleware->trustProxies(at: [
'0.0.0.0',
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();I don't have a specific ask here - just wanted to share in case it helps anyone 🙂 |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
Bug description
I installed a new site using the Statamic CLI to test a solo site and decided to deploy to my home server behind a reverse proxy. I updated .env APP_URL to the secure URL and brought up the site. The frontend works fine, and control panel mostly works but content is partially loading due to insecure/mixed content. Checking network tabs shows Axios XHR requests sent to the site URL but over HTTP.
Is there some build command I should run after updating APP_URL? I've run every artisan command I can think of. Naturally my thought is to use a middlware but I just noticed there's no
Kernel.phpin this site. Should I be adding statamic to an existing Laravel installation?This seems like a very simple thing I'm missing. If I paste and navigate directly to these HTTP URLs they properly redirect and the content is rendered. It's just CORS that's failing. How can we disable or configure CORS in a statamic site? Are we expected to do this on the web server? What's going on?
How to reproduce
Use ngrok to simplify and illustrate the behavior:
Install a new Statamic site, login to cp, do stuff. It works.
Install ngrok and serve
brew install ngrokphp artisan servengrok http 8000Update
.envAPP_URL to public HTTPS endpoint.Navigate to HTTPS endpoint see everything is loading via HTTP.
Logs
Environment
Installation
Starter Kit using via CLI
Additional details
No response
Beta Was this translation helpful? Give feedback.
All reactions