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

500 on Fetching Images #216

Closed clemsonfan101 closed 2 months ago

clemsonfan101 commented 2 months ago

Preface

This is my first project using open-next, so there's a good chance of some misunderstanding on my part. I'd like to say "bravo" on this project, because it basically "just works" from near 0. My front-end deployed successfully into my existing cdk stack with almost 0 effort.

Problem

I have one problem with my deployment. I noticed that my images aren't coming down to the browser. The client is getting a 500 response with the following response (0 , fs.fetchInternalImage) is not a function.

I'm using open-next:^2.3.9. I'm using "cdk-nextjs-standalone": "^4.0.0-beta.27". Here's what my stack looks like:

import { Nextjs } from "cdk-nextjs-standalone";
//Front-End
    const nextjs = new Nextjs(this, "nextjs", {
      nextjsPath: "../path/to/root/of/next/project",
      buildCommand: "npx open-next@^2 build",
      // skipBuild: true,
      domainProps: {
        domainName: "{my domain name}",
        certificate: {my certificate},
        certificateDomainName: "{my cert's domain name}",
      },
    });

It's also interesting to note that I cannot seem to find any logs in CloudWatch at all that correspond to this 500.

clemsonfan101 commented 2 months ago

I ended up resolving the problem. Posting the resolution here in case anyone runs into it. Turned out to be a compatibility issue between my next version 14.0.3 and open-next. I went through the commit history and found that function got added in 14.1.1. Upgrading to that version of next solved the issue.

Closing this issue.