在 dev env 中,这工作正常,但现在我已准备好投入生产,但无法正常工作.当我点击它时,它会将其转换为:
https://test.example.com/auth/security_questions/f%3Dru&i%3D101083&k%3D7014c315f3056243534741610545c8067d64d747a981de22a90d/code/b129025
这会阻止 react-router-dom
匹配正确的 URL,因此 Web 应用程序的一部分无法正确加载.
使用以下内容构建链接.
link = '%s/auth/security_questions/f=%s&i=%s&k=%s' % \('https://test.example.com', 'ru', user.id, user.key)
此外,这是捕获路由的url()
:
url(r'^(?:.*)/$', TemplateView.as_view(template_name='index.html')),
解决方案
这些变量应该是 queryGET 请求中的参数.当您构建链接时,您需要在其中将 URL 与查询字符串分开的地方有一个问号:
https://test.example.com/auth/security_questions/?f=ru&i=101083&k=7014c315...^|___这里
=
到 url 编码的 %3D
等的转换是正确的,等效的.有时变量直接是 URL 的一部分,但在这种情况下,Web 应用程序不使用 & 分隔的键/值对.
Working on a Django/React app. I have some verification emails links that look like the following:
https://test.example.com/auth/security_questions/f=ru&i=101083&k=7014c315f3056243534741610545c8067d64d747a981de22fe75b78a03d16c92
In dev env this works fine, but now that I am getting it ready for production, it isn't working. When I click on it, it converts it to:
https://test.example.com/auth/security_questions/f%3Dru&i%3D101083&k%3D7014c315f3056243534741610545c8067d64d747a981de22fe75b78a03d16c92/
This prevents react-router-dom
from matching the correct URL, so a portion of the web application does not load properly.
The link is constructed using the following.
link = '%s/auth/security_questions/f=%s&i=%s&k=%s' % \
('https://test.example.com', 'ru', user.id, user.key)
Also, here is the url()
that is catching the route:
url(r'^(?:.*)/$', TemplateView.as_view(template_name='index.html')),
解决方案