对于部署在具有CloudFront的S3上部署的VueJS应用程序,“指定的密钥不存在”

问题描述 投票:1回答:1

我使用Route53在S3和CloudFront上部署了VueJS应用程序。好像一切都运转正常。我可以访问https://my-domain.com的网站,我可以导航到我用Vue路由器设置的不同路由。但是,当我尝试直接访问https://my-domain.com/about时,我看到以下错误:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<link type="text/css" id="dark-mode" rel="stylesheet" href=""/>
<style type="text/css" id="dark-mode-custom-style"/>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>about</Key>
<RequestId>8371CJFJ48JM68239</RequestId>
<HostId>
/fQp7V6SuN0eDPgZpTroQrrxmfVQJTjXtroij56OIJONB56048OIaZDa4snkjc/Ygr/oZu0=
</HostId>
</Error>

以下是我的AWS资源的设置:

S3水桶

Properties

所有属性都被禁用(我没有静态网站托管集,因为我使用的是https)

Permissions (Public)

Public Access Settings

所有四个选项都设置为false

Access Control List

公共访问:每个人都可以阅读和列出对象

Bucket Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadForGetBucketObjects",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::mybucketname.com/*"
        }
    ]
}

CORS configuration

这里什么都没设置

Route53

我有一个域名,其托管区域包含5条记录:

  • mydomain.com:记录;指向CloudFront分配
  • 我没有更改的默认NS和SOA记录
  • * .mydomain.com:记录;还指向前端子域的CloudFront分配
  • api.mydomain.com:记录;指向后端API服务的ALB

CloudFront的

以下是我的CloudFront分配的General设置:

Distribution ID: 12356OIJSGSU9I
ARN: arn:aws:cloudfront::123456789012:distribution/ABCD1234
Log Prefix: -
Delivery Method: Web
Cookie Logging: Off
Distribution Status: Deployed
Comment: -
Price Class: Use All Edge Locations (Best Performance)
AWS WAF Web ACL: -
State: Enabled
Alternate Domain Names (CNAMEs):
*.mydomain.com
mydomain.com
SSL Certificate: mydomain.com (abc1234-1234-1234-1234-abcd1234)
Domain Name: abcd1234.cloudfront.net
Custom SSL Client Support: Only Clients that Support Server Name Indication (SNI)
Security Policy: TLSv1.1_2016
Supported HTTP Versions: HTTP/2, HTTP/1.1, HTTP/1.0
IPv6: Enabled
Default Root Object: index.html
Last Modified: 2019-02-19 11:45 UTC-5
Log Bucket: -

我没有设置任何原始组。我不确定我是否需要这个,但听起来它可以帮助解决这个问题。

我也听说过AWS Amplify(https://console.aws.amazon.com/amplify/)。

我可以更改哪些设置以便将对域的非root请求路由到VueJS应用程序?

amazon-web-services vue.js amazon-s3 amazon-cloudfront amazon-route53
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.