lib icon indicating copy to clipboard operation
lib copied to clipboard

AWS - Deploy into S3 (locale-router-static)

Open 9christian9 opened this issue 2 years ago • 1 comments

Ciao, for my needs I am using examples/locale-router-static to generate my static website to upload to the S3 bucket. But I cannot configure S3 correctly.

When I work with a static website that I deploy in S3, I only use a page called index.html as the default index, but in this case, Sveltekit (svelte.config.js) generates more than a single page and I don't know how to configure my s3 bucket.

Could anyone help me with this?

Regards, Christian.

9christian9 avatar Jul 29 '22 12:07 9christian9

Ciao,

I found a solution...which is not the best but for now works as expected 😄 suppose we have 2 languages like en and en

  1. in the root of the project we create an empty file called for example index
  2. run (in my case) npm run build or npx run build
  3. load the files present in the build folder in s3
  4. load the empty index file in the root of s3
  5. click on the index file -> go to Properties -> metadata section and click on edit -> set x-amz-website-redirect-location as /it/ and save

Configuring s3:

  1. Static website hosting set to true
  2. index document set to index
  3. Error document - optional set to en.html
  4. Redirection rules: optional set to the following:

[ { "Condition": { "HttpErrorCodeReturnedEquals": "/it" }, "Redirect": { "ReplaceKeyWith": "/it/" } }, { "Condition": { "HttpErrorCodeReturnedEquals": "/en" }, "Redirect": { "ReplaceKeyWith": "/en/" } } ]

Remember that the more languages there are, the more rules you have to add. I hope this can help someone.

Christian

9christian9 avatar Aug 29 '22 20:08 9christian9