gpt4 book ai didi

css - 如何修复无效请求(不支持的 SSL 请求)

转载 作者:可可西里 更新时间:2023-11-01 16:12:21 25 4
gpt4 key购买 nike

我正在设置我的 laravel 应用程序,每次运行 php artisan serve 时,它​​都会在 localhost:8000 启动 laravel 开发服务。但是,当我在浏览器上打开 locahost 链接时,它会强制将 http 转换为 https 并记录无效请求(不支持的 SSl 请求)。您建议我如何解决此问题?

我已经尝试在 .htaccess 文件上将 HTTPS mod 重写规则强制为 http://,但它仍然存在。

这是命令行

C:\Users\topaz\cashurban>php artisan serve
Laravel development server started: <http://127.0.0.1:8000>
[Thu Aug 22 23:06:07 2019] 127.0.0.1:60410 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60418 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60419 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60420 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60421 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60423 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60409 [200]: /assets/img/slider-1.jpg
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60425 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60426 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60427 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60411 [200]: /assets/img/slider-2.jpg
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60435 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60437 [200]: /assets/img/slider-3.jpg
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60439 [200]: /assets/img/icon-1-1.png
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60438 [200]: /assets/img/images/index-Recovereddashboard_03.png
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60440 [200]: /assets/img/icon-2-1.png
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60442 [200]: /assets/img/icon-3-1.png
[Thu Aug 22 23:06:08 2019] 127.0.0.1:60447 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60448 [200]: /assets/img/tor1.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60450 [200]: /assets/img/tor2.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60452 [200]: /assets/img/tor3.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60455 [200]: /assets/img/images/visa.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60453 [200]: /assets/img/images/remita.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60454 [200]: /assets/img/images/master-card.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60460 [200]: /assets/img/images/verve.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60461 [200]: /assets/img/images/indexpartners_11.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60462 [200]: /assets/img/images/bank-branches.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60463 [200]: /assets/img/images/indexpower_03.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60464 [200]: /assets/img/images/paystack.png
[Thu Aug 22 23:06:09 2019] 127.0.0.1:60465 [200]: /assets/img/images/chams.png
[Thu Aug 22 23:06:10 2019] 127.0.0.1:60468 Invalid request (Unsupported SSL request)
[Thu Aug 22 23:06:10 2019] 127.0.0.1:60469 Invalid request (Unsupported SSL request)

这是 .htaccess 文件

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On

#Force Https

#RewriteCond %{HTTPS} !=on
#RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d

#Api Redirect
RewriteCond %{REQUEST_URI} (.+)/$
#RewriteRule ^/api$ api.%{REQUEST_URI} [L,R=301]


RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

#GZip Compression
<ifModule mod_gzip.c>
#mod_gzip_on Yes
#mod_gzip_dechunk Yes
#mod_gzip_item_include file .(html?|txt|css|js|php|xml|json|pl)$
#mod_gzip_item_include handler ^cgi-script$
#mod_gzip_item_include mime ^text/.*
#mod_gzip_item_include mime ^application/x-javascript.*
#mod_gzip_item_exclude mime ^image/.*
#mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

#php_value auto_prepend_file /home/example_project/public_html/error_handler_slack.php
php_value auto_prepend_file error_handler_slack.php
</IfModule>

我希望它在 http://localhost 上转换而不是 https://localhost因为它当前正在重定向

最佳答案

我后来解决了这个问题,以防万一以后有人遇到类似的问题,我发现 AppServiceProvider 类有一个 register 方法,其中注册了一个安全拦截中间件以强制每个 HTTP 请求到 HTTPS。因此,我编写了一个 if-else 逻辑,只允许在生产环境中执行此操作,因为我的本地主机没有 SSL 证书。

在 app/providers/AppServiceProvider.php 中

寻找register() 方法,然后通过检查应用程序是否为本地来实现逻辑。 isLocal() 方法检查您的 .env 文件中的 APP_ENV 变量,如果它是本地变量则返回 true,因此您再次确认它已设置为本地变量并确保清除所有先前的配置缓存。

//check that app is local
if ($this->app->isLocal()) {
//if local register your services you require for development
$this->app->register('Barryvdh\Debugbar\ServiceProvider');
} else {
//else register your services you require for production
$this->app['request']->server->set('HTTPS', true);
}

关于css - 如何修复无效请求(不支持的 SSL 请求),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57617864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com