sst / open-next

Open source Next.js serverless adapter
https://open-next.js.org
MIT License
3.73k stars 113 forks source link

NextJs application cannot reach api gateway #347

Closed jimmyd-be closed 6 months ago

jimmyd-be commented 6 months ago

We moved our application to NextJs and using open-next/sst to deploy to AWS. Now when we go to the website all the calls to api gateway url is throwing an 401 unauthorazed exception.

The api gateway rest api is not changed between the newer frontend. The current configuration for us looks like below. Can someone help me with this? This is the only stopper to put this in production.

import { type SSTConfig } from 'sst';
import { NextjsSite } from 'sst/constructs';

export default {
  config(_input) {
    return {
      name: 'XXXX-' + _input.stage,
      region: _input.region
    };
  },
  stacks(app) {
    app.stack(function Site({ stack }) {
      app.setDefaultFunctionProps({
        architecture: 'arm_64',
        runtime: 'nodejs18.x',
        timeout: 30
      });

      const site: NextjsSite = new NextjsSite(stack, 'XXXX', {
        warm: 5,
        buildCommand: 'npx open-next@latest build',
        customDomain: {
          domainName: 'test.test.com',
          hostedZone: 'test.com'
        },
        runtime: 'nodejs18.x',
        memorySize: 512
      });

      stack.addOutputs({
        SiteUrl: site.url
      });
    });
  }
} satisfies SSTConfig;

We are using SSt 2.39.2 and open-next 2.3.4

conico974 commented 6 months ago

It doesn't seem related to open-next, open-next doesn't modify any of your external api call. How are you accessing your api ? Anyway, you'll probably find more help in the sst discord by creating a help thread