仅当指定“位置”查询参数时,AWS Amplify 才会返回 403 错误

Pip*_*ipe 7 amazon-web-services aws-amplify

我有一个使用 AWS Amplify 托管的网站,每个具有location查询参数的 URL 都会返回类似以下内容的内容:

403 Forbidden

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>THSG05EH8EYB1E7N</RequestId>
<HostId>n6Ycon+6kmnmIMiH47lLxNiXhXduG4QzJstmzNeEfBYy3AV19PisdKfXHN99LIAE2cZgvLJ1FBQ=</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)

假设我的网站是: https: //example.com

进入:

https://example.com --> works
https://example.com?anyotherparam=anyvalue --> works
https://example.com/ --> works
https://example.com/anyurl --> works
https://example.com/anyurl?anyotherparam=anyvalue --> works
https://example.com/any/sub/url -> works
https://example.com/any/sub/url?anyotherparam=anyvalue -> works
https://example.com?location --> returns 403
https://example.com?location?anyvalue --> returns 403
https://example.com/anyurl?location --> returns 403
https://example.com/anyurl?location=anyvalue --> returns 403
https://example.com/any/sub/url?location --> returns 403
https://example.com/any/sub/url?location=anyvalue --> returns 403
Run Code Online (Sandbox Code Playgroud)

知道什么会导致这种情况吗?

编辑:我不知道是否相关...但在 Amplify 重定向中,我配置了 AWSDoc 建议的 SPA 重定向规则:

Address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>
DestinationAddress: /index.html
RedirectType: 200
Run Code Online (Sandbox Code Playgroud)

mon*_*kut 0

对我来说,我将buildSpec>artifacts>files设置设置为“*”而不是“**/*”,因此任何不在 baseDirectory 中的文件都会导致 403。

更新files到“**/*”解决了该问题。

          artifacts:
            baseDirectory: dist/
            files:
              - '**/*'
Run Code Online (Sandbox Code Playgroud)

https://github.com/aws-amplify/amplify-hosting/issues/1403#issuecomment-749915604