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

NextJs 503 error randomly happening with custom Cache-Control header

Open utsavbshah opened this issue 3 years ago • 0 comments

Before opening, please confirm:

Region

us-west-1

Amplify Hosting feature

Custom headers

Describe the bug

I am getting random 503 errors for the build related files. i.e. while accessing the css and js files I am getting 503 error from the CloudFront. image

The response should be cached in the CloudFront but the request goes to the origin and in the error logs it gives OriginError. In my logs file I am getting,

x-edge-result-type: Error x-edge-response-result-type: Error x-edge-detailed-result-type: OriginError

Expected behavior

There should not be any 503 errors.

Reproduction steps

This is fully random behaviour so there is not any reproduction steps for this.

Build Settings

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - nvm use $VERSION_NODE_16
        - npm install
    build:
      commands:
        - nvm use $VERSION_NODE_16
        - npm run build:stage
  artifacts:
    baseDirectory: out
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
      - .next/cache/**/*

Additional information

My customHeaders.yml file: customHeaders:

  • pattern: '**/*.html' headers:
    • key: Cache-Control value: 'public, max-age=0, must-revalidate'
  • pattern: '**/*[!.html]' headers:
    • key: Cache-Control value: 'public,max-age=31536000,immutable'

utsavbshah avatar Aug 10 '22 11:08 utsavbshah