DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on • Edited on

1

Access Denied after Deploying NuxtJs on AWS Amplify

If you are getting similar error after deploying NuxtJs on AWS Amplify:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>69F14474972D101F</RequestId>
<HostId>
...
</HostId>
</Error>
Enter fullscreen mode Exit fullscreen mode

Here is the solution that might work for you.

Step 1. Update Build Settings

Login to AWS Amplify > Select the App > Build settings > Click on Edit.

  • Set the build commands to npm run generate
  • Set the baseDirectory location to be dist or dist/ whichever works for you.

Your amplify.yml will look like:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run generate
  artifacts:
    baseDirectory: dist/
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
Enter fullscreen mode Exit fullscreen mode

Step 2. Rewrites and redirects

Click on Rewrites and redirects > Edit > Open text editor and enter following:

[
    {
        "source": "/<*>",
        "target": "/index.html",
        "status": "404-200",
        "condition": null
    }
]
Enter fullscreen mode Exit fullscreen mode

Then click on Save.

After completing these steps, redeploy the app, it should work.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (1)

Collapse
 
softlaza profile image
SoftLaza

I try by adding slash / after dist/
if not i got error on deployment

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay