jetbridge / cdk-nextjs

Deploy a NextJS application using AWS CDK
https://constructs.dev/packages/cdk-nextjs-standalone
Apache License 2.0
261 stars 43 forks source link

When deploying the Distribution the CachePolicy creation returns 400 Bad request #189

Closed AlbertSabate closed 7 months ago

AlbertSabate commented 7 months ago

When deploying the Distribution, the CachePolicy creation returns 400 Bad request. As a result deploying a next app with all defaults will not work.

A way to fix it will be to use override:

overrides: {
      nextjsDistribution: {
        imageResponseHeadersPolicyProps: {},
        serverCachePolicyProps: {
          headerBehavior: CacheHeaderBehavior.allowList(
            'accept',
            'rsc',
            'next-router-prefetch',
            'next-router-state-tree',
            'next-url',
            'x-prerender-revalidate',
          ),
        },
      },
    },

There is a conflict between accept-encoding and enableAcceptEncodingGzip: true. Being set both at the same time.

AlbertSabate commented 7 months ago

PR: https://github.com/jetbridge/cdk-nextjs/pull/188

Fixes the issue.