简体   繁体   English

S3 静态托管停用 URL 编码

[英]S3 static hosting deactivate URL encoding

I'm using the s3 static hosting for an react app.我正在为 React 应用程序使用 s3 静态托管。

Its handed a jwt token which contains a URL, decoded it looks like this:它传递了一个包含 URL 的 jwt 令牌,解码后如下所示:

app/{version}/index.html

the {version} part is replaced with a version number: {version} 部分替换为版本号:

url.replace('{version}', "v".concat(apiVersion))

locally this works fine but in s3 the URL looks like this:在本地这工作正常,但在 s3 中,URL 如下所示:

app/%7Bversion%7D/index.html

Is there any why to prevent the URL encoding in s3 on the jwt decode?有什么原因要在 jwt 解码时阻止 s3 中的 URL 编码?

also did add也确实添加了

url.replace('%7Bversion%7D', "v".concat(apiVersion))

which works then in s3 but not locally.然后在 s3 中工作,但在本地不工作。

Also tried to configure redirect rules, but did not work.还尝试配置重定向规则,但没有用。

You can use decodeURI .您可以使用decodeURI

decodeURI(url).replace('{version}', "v".concat(apiVersion))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM