inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

form.post produces Mixed Content: The page at 'domain' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint

Open Arturexe opened this issue 3 years ago • 0 comments
trafficstars

I've been trying to resolve an error that happens only in production. When I try to create a new database entry, following errors are thrown:

Mixed Content: The page at 'https://strong-moebel.art/admin/gallerie/neu' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://strong-moebel.art/admin/gallerie'. This request has been blocked; the content must be served over HTTPS.
Uncaught (in promise) Error: Network Error
    at wh (main.750d1ea1.js:4:96980)
    at s.onerror (main.750d1ea1.js:5:1837)

everything else works, including the edit method of the entries. I'm using a resource controller. create method uses inertia's form.post and edit method uses its form.put.

I've been trying to debug this with the solutions provided in:

  1. Mixed content issue- Content must be served as HTTPS
  2. Mixed Content (laravel)

basically people are saying to add:

if (App::environment('production')) {
    URL::forceScheme('https');
}

to the boot() method of your AppServiceProvider.php. I've done so but the error still occurs.

On the server, I've tried:

APP_ENV=production
APP_URL=http://localhost
APP_URL=https://localhost
APP_URL=
APP_URL=http://strong-moebel.art
APP_URL=https://strong-moebel.art

but nothing seems to solve the issue. My webhost is cloudways and I'm using their Let's Encrypt SSL Certificate. I've also tried to remove the certificate and see what happens but even then the exact same error occurs.

I'm using vite to build production built.

Arturexe avatar Jun 12 '22 07:06 Arturexe