s3 cloudfront app代码:NoSuchKey令人耳目一新

Jan*_*ier 3 amazon-s3 amazon-web-services node.js amazon-cloudfront angular

我在s3中托管了我的angular2 webapp.它也有云端.它连接到nodejs作为后端,它位于AWS EBS中的不同机器中.

我的Web应用程序工作正常.但是当我刷新任何页面时,它会抛出404 Not Found with the message.

Code: NoSuchKey
Message: The specified key does not exist.
Key: user/adduser/edit
RequestId: CA306FFABB30FB75
HostId: WAp7/BZMHH0UpE3z2dJLJT4gqEwv7u/LKbFTUuHH86lRyReLXvODLgTuTw+3emnTJ3jDj2VpiYo=
Run Code Online (Sandbox Code Playgroud)

你能帮忙解决这个问题吗?

Jan*_*ier 6

我不确定它是否正确.但它解决了我的问题.我将s3 404重定向url配置为我的index.html.ie将我的404重定向指向index.html本身.有效.

  • 我们为403和404配置Cloudfront错误处理程序,以返回具有200 OK状态的index.html.在测试中,无论返回是200还是404,Angular2应用程序都会处理它.它在Inspector中看起来更好看,404不是红色. (3认同)