XMLHttpRequest 在 AWS Amplify 上请求失败 HTML

XMLHttpRequest fail on AWS Amplify for requesting HTML

我正在尝试使用 Jquery 的 ajax 方法来请求将文档加载到我在 AWS amplify 上的页面中。我从 Amplify 收到 403 错误,即使脚本和请求的文档托管在同一站点上。

我在我的网页中的 Chrome 开发者控制台试过这个:

$.ajax({type:"GET", url : "/_status_normal.inc"}).done(r=>console.log(r));

回复:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>K1EQ6385K38BZRWK</RequestId>
<HostId>rebHmO5sssss/pqNIomerEo/mVbCVliqu6sycTOXfc=</HostId>
</Error>

如何使用 jQuery 和 AWS Amplify 创建简单的 XMLHTTPRequest?

请求这些本地资源时'/'是错误的。正确的要求是:

$.ajax({type:"GET", url : "_status_normal.inc"}).done(r=>console.log(r));

API 网关是设置 HTTP GET/POST 请求和禁用 CORS 的 AWS 方法。

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html