前提・実現したいこと
テスト環境で発生しているMixed Content: The page atエラーを解決したい
該当のソースコード
現在Laravelのデフォルト機能で生成しているページネーションのURLがテスト環境でもhttpから始まっており上記のエラーが発生しています
ローカル環境のhttpとテスト環境のhttpsでエラーが起きないようにしたいのですがどのようにしたらよいでしょうか?
@if(isset($Users)==true) @if(count($Users)>=5) {{ $Users->links() }} @endif @endif
試したこと
https://laracasts.com/discuss/channels/laravel/mixed-content-issue-content-must-be-served-as-https
のサイトを元に
Provider/AppServiceProvider.phpを下記のように変更しました
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Routing\UrlGenerator; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot(UrlGenerator $url) { if(env('APP_ENV') !== 'local') { $url->forceSchema('https'); } } /** * Register any application services. * * @return void */ public function register() { // } }
変更した結果
ページネーションの表示されるページでこのようなエラーが起きてしまいました
/app/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php if (static::$macros[$method] instanceof Closure) { return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters); } return call_user_func_array(static::$macros[$method], $parameters); } /** * Dynamically handle calls to the class. * * @param string $method * @param array $parameters * @return mixed * * @throws \BadMethodCallException */ public function __call($method, $parameters) { if (! static::hasMacro($method)) { throw new BadMethodCallException("Method {$method} does not exist."); } $macro = static::$macros[$method]; if ($macro instanceof Closure) { return call_user_func_array($macro->bindTo($this, static::class), $parameters); } return call_user_func_array($macro, $parameters); } } Arguments "Method forceSchema does not exist."
Illuminate\Contracts\Routing\UrlGenerator そのものは下記のようになっていました
UrlGeneratorでforceSchema を定義する必要があるということなのでしょうか?
ページネーションを付けたことで出現したMixed Content: The page atをなくすにはどのようにするのが一番よいでしょうか?
<?php namespace Illuminate\Contracts\Routing; interface UrlGenerator { /** * Get the current URL for the request. * * @return string */ public function current(); /** * Generate an absolute URL to the given path. * * @param string $path * @param mixed $extra * @param bool $secure * @return string */ public function to($path, $extra = [], $secure = null); /** * Generate a secure, absolute URL to the given path. * * @param string $path * @param array $parameters * @return string */ public function secure($path, $parameters = []); /** * Generate the URL to an application asset. * * @param string $path * @param bool $secure * @return string */ public function asset($path, $secure = null); /** * Get the URL to a named route. * * @param string $name * @param mixed $parameters * @param bool $absolute * @return string * * @throws \InvalidArgumentException */ public function route($name, $parameters = [], $absolute = true); /** * Get the URL to a controller action. * * @param string $action * @param mixed $parameters * @param bool $absolute * @return string */ public function action($action, $parameters = [], $absolute = true); /** * Set the root controller namespace. * * @param string $rootNamespace * @return $this */ public function setRootControllerNamespace($rootNamespace); }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/09 10:15