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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️