Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Some files and Forms Being Served Over HTTP Instead of HTTPS #1622

Closed
davidkobielski opened this issue Sep 19, 2024 · 4 comments
Closed

Some files and Forms Being Served Over HTTP Instead of HTTPS #1622

davidkobielski opened this issue Sep 19, 2024 · 4 comments

Comments

@davidkobielski
Copy link

Hi,

I've encountered a strange issue where files like CSS, JS, and icons are being served over HTTP instead of HTTPS, which shouldn’t happen.

In my .env file, I have APP_URL set to HTTPS. HTML files and SVG logos are returned correctly over HTTPS, but the problem occurs with JS, CSS, and favicon files—they are served over HTTP.

Additionally, form URLs are also rendered with HTTP, for example:

<form action="http://domain.com/admin/#">

It seems the issue is related to the application. Could you help me investigate this?

Thanks in advance!

image

@davidkobielski
Copy link
Author

I fixed the issue. I had to force https in code.

Added forceSchema to boot function in app/Providers/AppServiceProvider.php

# importing URL
use Illuminate\Support\Facades\URL;

# Added forceSchema to boot function
public function boot()
    {
        URL::forceScheme('https');
    }

I don't think it's good, can we talk about why I had to do this?
I'm working on Krayin Docker installation to make Krayin easier to install, and everything works ok, but I have these issue with https only.

@suraj-webkul
Copy link
Collaborator

We are using asset() and route() helpers to generate correct URLs with the appropriate protocol (HTTP or HTTPS), the APP_URL in your .env file should be set correctly. Here's how to fix the issue:

Update the APP_URL in your .env file: Ensure that the APP_URL is using the correct protocol (either HTTP or HTTPS) depending on your environment.

For HTTPS:

APP_URL=https://your-domain.com

For HTTP:

APP_URL=http://your-domain.com

Clear the configuration cache, using below command, After updating the .env file, you need to clear the cache to apply the changes. Run the following command:

php artisan optimize:clear

@davidkobielski
Copy link
Author

@suraj-webkul
thank you for the response.

I did what u wrote above. I have https url in the env file
Also I cleared few times cache and everything.
Even destroyed a docker container and created a new one.

@devansh-webkul
Copy link
Member

Hi @davidkobielski,

Sometimes, it can be caused by a hot file. You can check the public folder for any hot files, and if found, simply delete them.

Alternatively, you can run npm run dev in the Admin package as well.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants