File Uploading problem 401 Error.

[Everything works fine In local Environment]
Hello, I have this problem I'm using ngrok-free to host my app locally to test my app in online. Everything work's fine like loading image assets but when I try to Upload image using FileUpload it cause problem.
btw I didn't face this problem If I use normal upload Like using blade and controller. Here Is My setup that usually work with normal app.

File Upload
    FileUpload::make('thumbnail')
         ->image()
         ->imageEditor()
         ->imageCropAspectRatio('16:9')
         ->disk('products')
         ])->columnSpan(1)


AppServiceProvider
 public function boot(): void
    {
        if (\App::environment(['production', 'local'])) {
            URL::forceScheme('https');
        }
    }


Env
APP_NAME=asm
APP_ENV=local
APP_KEY=base64:szgyQjydWBZVod7BWujDG/ZYa8CIa94UmPKNeekbgko=
APP_DEBUG=true
APP_URL=https://recently-amusing-hedgehog.ngrok-free.app

ESSION_DOMAIN=.ngrok-free.app
SESSION_SECURE_COOKIE=true

SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,::1,ngrok-free.app,https://recently-amusing-hedgehog.ngrok-free.app
Screenshot_2025-05-22_205022.png
Solution
I think ->trustProxies() is the right way. I think you can add your ngrok IP to limit this, but I don't think there is a high risk when you keep your ngrok URL to yourself.
Was this page helpful?