URL生成器将"localhost"放入在Laravel域之前 [英] URL generator putting "localhost" before domain in Laravel
问题描述
我一直在尝试通过签名URL向用户发送验证链接在Laravel中.似乎可以正常运行,但是使用URL外观构建链接时,链接显示不正确.
I've been trying to email users a verification link using signed URLs in Laravel. It seems to work okay, but the link comes out incorrect when it is built using the URL facade.
public function toMail($notifiable)
{
$url = URL::signedRoute('confirm', ['user' => $this->user->id]);
return (new MailMessage)
->subject('Activate your email address')
->line('In order to use the application, please verify your email address.')
->action('Activate your account', $url)
->line('Thank you for using our application!');
}
在电子邮件中,链接看起来像:
In the email, the link looks like:
http://localhost/mydomain.com/confirm/14?signature=3ba4d86827717440f70a3b2f60c913b6e84d550cb9fce8de04a8ba359833ac7c
http://localhost/mydomain.com/confirm/14?signature=3ba4d86827717440f70a3b2f60c913b6e84d550cb9fce8de04a8ba359833ac7c
本地主机"部分不应存在.但是,如果我在URL栏中手动将其删除,则相信操作URL的签名URL会导致401错误.我在本地主机环境上运行,但是我使用Laragon的自动虚拟主机,因此仍然可以在域中运行它.
The "localhost" part should not be there. However, if I manually delete it in the URL bar, I believe the signed URL things I manipulated the URL and gives me a 401 error. I am running on a localhost environment but I use Laragon's auto virtual host so that I can still run it with a domain.
有什么建议吗?
推荐答案
更改:
APP_URL = example.com
APP_URL=example.com
收件人:
APP_URL = http://example.com
我猜不指定"http://"会将localhost附加到前面.希望这可以帮助某人!
I guess not specifying "http://" makes it append localhost to the front. Hope this helps someone!
这篇关于URL生成器将"localhost"放入在Laravel域之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!