在电子邮件模板 TWIG 中获取完整的 url

问题描述 投票:0回答:1

我正在使用 Symfony 6 开发一个应用程序,我安装了重置密码包。除了我收到要求更改密码的电子邮件外,一切都运行良好。 TWIG 中通过“url”函数的重定向不会重定向到正确的 url。当我单击电子邮件中的链接时,url 将我发送到 localhost/mypagepath/token,这给了我一个 404。当我写 https://localhost:8000/mypagepath/token 时,它起作用了,我得到了更改密码的表单。我不明白为什么 url twig 函数不包含 scheme 和 port 。我正在使用 symfony 服务器在开发环境中运行我的应用程序。

这是树枝中的线。我没有改变这是捆绑包中默认的模板。

<p>To reset your password, please visit the following link</p>

<a href="{{ url('app_reset_password', {token: resetToken.token}) }}">{{ url('app_reset_password', {token: resetToken.token}) }}</a>

<p>This link will expire in {{ resetToken.expirationMessageKey|trans(resetToken.expirationMessageData, 'ResetPasswordBundle') }}.</p>

我尝试更改 routing.yaml 文件中的默认 uri

default_uri: https://localhost:8000

它添加了 https 但没有添加端口,所以链接仍然不起作用。

我还尝试将 url 函数更改为 absolute_url。

提前感谢您的帮助。

php symfony twig phpmailer
1个回答
0
投票

请写

default_url
而不是
default_uri

© www.soinside.com 2019 - 2024. All rights reserved.