amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Remove default Rewrites and redirects rules for Nuxt SSR

Open trandaison opened this issue 2 years ago • 3 comments

Before opening, please confirm:

  • [X] I have checked to see if my question is addressed in the FAQ.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

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

trandaison avatar Nov 26 '23 10:11 trandaison

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?

Narrator avatar Nov 26 '23 17:11 Narrator

@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.

trandaison avatar Nov 27 '23 01:11 trandaison