CloudFront Spa子Path,无S3托管
我在S3中有一个水疗应用程序。 EC2中的API
我的CloudFront Logic如下:
- /-Api-Origin
- /front/* - S3-Bucket-Origin
Front具有其方式,例如
- example.com/front/front/login/login
- example.com/front/documents/
- example.com/front/usersetting/
我设法通过托管代理来启动该应用程序。但是我想尝试在不启用S3托管的情况下实现此目标。
我尝试了什么:
为前部行为添加了CloudFront功能。
function handler(event) {
var request = event.request;
request.uri = request.uri.replace(/^\/[^/]*\//, "/");
request.uri += '/front/index.html';
return request;
}
但是我得到404
,请告诉我如何正确实施。最好没有lambda(仅云范围功能)
I have a SPA app in S3. Api in EC2
My cloudfront logic is as follows:
- / - api-origin
- /front/* - s3-bucket-origin
The front has its ways, for example
- example.com/front/User/Login
- example.com/front/Documents/
- example.com/front/UserSetting/
I managed to launch the application through s3 bucket hosting proxy. But I want to try to implement this without s3 hosting enabled.
What did I try:
Added cloudfront function for front behavior.
function handler(event) {
var request = event.request;
request.uri = request.uri.replace(/^\/[^/]*\//, "/");
request.uri += '/front/index.html';
return request;
}
But I get 404
Please tell me how to implement this correctly. Preferably without Lambda (only cloudfront functions)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为自己找到了解决方案。我不知道这有多正确,但它有效。
我希望CloudFront功能不会花很多钱
Found a solution for myself. I don't know how correct this is, but it works.
I hope cloudfront functions don't cost a lot of money