aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
451 stars 113 forks source link

Remove default Rewrites and redirects rules for Nuxt SSR #3829

Open trandaison opened 9 months ago

trandaison commented 9 months ago

Before opening, please confirm:

App Id

d1cs14y4x3ieze

AWS Region

ap-southeast-1

Amplify Hosting feature

Redirects, SSR

Frontend framework

Vue

Next.js version

Nuxt Version: 3.8.2

Next.js router

N/A

Describe the bug

Amplify has these Rewrites and redirects settings by default.

Screenshot 2023-11-26 at 17 40 13

However, it's not working for a Nuxt SSR app, because nuxt build does not create any index.html file, it will keep redirecting to /index.html for every routes.

Expected behavior

These settings should not be set by default for Nuxt SRR applications.

Reproduction steps

  1. Init a Nuxt 3 repo.
  2. Create some pages, for example: /login
  3. Deploy to Amplify (https://aws.amazon.com/blogs/mobile/introducing-support-for-hosting-any-ssr-app-on-aws-amplify-hosting/)
  4. Visit the login page main.<app-id>.amplifyapp.com/login

It redirect to /index.html, since this file does not exist it will show 404 error.

Build Settings

No response

Log output

``` # Put your logs below this line ```

Additional information

No response

Narrator commented 9 months ago

Hi @trandaison :wave: !

Thanks for reaching out to us. To immediately unblock yourself, please remove the second rewrite rule from your app - It should prevent the 404 error from occurring.

Aside from that, could you please confirm if you have vue as a separate dependency in your package.json? If so, could you please explain your use case for that?

trandaison commented 9 months ago

@Narrator Thanks for replying!

Thanks for reaching out to us. To immediately unblock yourself, please remove the second rewrite rule from your app - It should prevent the 404 error from occurring.

Actually, I had to remove all 2 rules, because the first one will cause redirect to /index.html when I visit the home page.

Aside from that, could you please confirm if you have vue as a separate dependency in your package.json? If so, could you please explain your use case for that?

Yes I do have vue in dependencies, I also have nuxt in devDependencies as well. By default, nuxt create a package.json with both nuxt and vue as separate dependencies.