Laravel重置密码链接中的域错误 [英] Laravel wrong domain in reset password link

查看:75
本文介绍了Laravel重置密码链接中的域错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在laravel 5.8中具有两次域的sendResetLinkResponse控制器生成了错误的URL.

I'm getting a bad URL generated by sendResetLinkResponse controller in laravel 5.8 having the domain twice.

https://api.domain.org/domain.org/password/重置/ ....

但是应该是

https://api.domain.org/password/reset/. ..

APP_URL设置为

The APP_URL is set to

APP_URL = domain.org

APP_URL=domain.org

我使用自定义配置以能够将api.domain.org用作端点,而不是www.domain.org/api

I use a custom config to be able to have as endpoint api.domain.org instead of www.domain.org/api

我的配置是:

protected function mapApiRoutes() {

 Route::domain('api.' .  env('APP_URL'))
   ->middleware('api')
   ->namespace($this->namespace)
   ->group(base_path('routes/api.php'));
}

我该如何解决?

推荐答案

我建议将您的子域设置为更具动态性,即

I would suggest setting up your subdomain to be more dynamic i.e.

Route::domain('api.{domain}')
    ->middleware(['api', function ($request, $next) {
        $request->route()->forgetParameter('domain');

        return $next($request);
    }])
    ->namespace($this->namespace)
    ->group(base_path('routes/api.php'));

上面的代码基本上允许使用任何域名,然后中间件将其从路由参数中删除,以免与路由闭包或控制器方法混为一谈.

The above basically allows for any domain name and then the middleware just removes it from your route params so that it doesn't mess with your route closures or controller methods.

您还需要将以下内容添加到服务提供商的启动方法中:

You will also need to add the following to the boot method of your service provider:

Route::pattern('domain', '[a-z0-9.]+');

这样,您可以使用APP_URL只是该站点的域.

This way you can use the APP_URL to just be the domain for the site.

这篇关于Laravel重置密码链接中的域错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆