sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.
MIT License
169 stars 19 forks source link

fix(83): API cache default #89

Closed lou-alfaro closed 1 year ago

lou-alfaro commented 1 year ago

fixes https://github.com/sladg/nextjs-lambda/issues/83

sladg commented 1 year ago

FYI, broke deployment

 ❌ Deployment failed: Error: The stack named SkiaDevStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: AWS::CloudFront::CachePolicy: The parameter HeaderBehavior is invalid for policy with caching disabled. (Service: CloudFront, Status Code: 400, Request ID: XYZ-28b8-427c-b52c-b7b854dc6e7f)" (RequestToken: XYZ-bc4a-4786-e454-03e8e142d52c, HandlerErrorCode: InvalidRequest)
    at FullCloudFormationDeployment.monitorDeployment (/XYZ/node_modules/aws-cdk/lib/index.js:397:10236)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.deployStack2 [as deployStack] (/XYZ/node_modules/aws-cdk/lib/index.js:400:149977)
    at async /XYZ/node_modules/aws-cdk/lib/index.js:400:135508
The stack named MyStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: AWS::CloudFront::CachePolicy: The parameter HeaderBehavior is invalid for policy with caching disabled. (Service: CloudFront, Status Code: 400, Request ID: XYZ-28b8-427c-b52c-b7b854dc6e7f)" (RequestToken: XYZ-bc4a-4786-e454-03e8e142d52c, HandlerErrorCode: InvalidRequest)

Fixed in version 7.0.5 https://github.com/sladg/nextjs-lambda/compare/v7.0.4...v7.0.5

lou-alfaro commented 12 months ago

Hey sorry about this breaking change. As I was implementing it we realized on our deploy that it failed, by that time we had forked because we needed some customization on the generated files and using some custom env variables we needed to have deployed as well so I didn't have the time to pick out my change with all the pollution I added that fixed it on the fork onto this one. Although I saw you're solution and that was much cleaner. We ended up setting the maxTtl: Duration.seconds(1), It didn't like the min, default, and max being set to 0 so that was the quick way we fixed it instead of digging into the cache policies. Thank you for fixing my mistake.