I’m trying to define an ApiGatewayV1Api which has ...
# sst
r
I’m trying to define an ApiGatewayV1Api which has two routes, one route which requires authentication via a custom lambda authorizer and a route that requires no authorization. When I deploy I get the error for the route without auth:
Copy code
Authorization type is set to NONE which is different from what is required by the authorizer [CUSTOM]
My definition looks like this:
Copy code
const api = new ApiGatewayV1Api(this, 'CustFeedbackApi', {
      defaultAuthorizer: authorizer,
      routes: {
        'POST /save': {
          function: 'src/handler/saveFeedbackHandler.handleSaveFeedback',
          methodOptions: {
            authorizationType: AuthorizationType.NONE,
          },
        },
        'GET /retrieve': {
          function:
            'src/handler/retrieveFeedbackHandler.handleRetrieveFeedback',
          methodOptions: {
            authorizationType: AuthorizationType.CUSTOM,
          },
        },
      },
    });
So, how do I set auth for one route but not another?
f
Hey @Ross Coundon, let me give that a try.
r
Thanks Frank, I’m just in the process of testing the opposite - setting default to NONE and setting the authoriser in methodOptions for the route with auth
f
got the same error on my side as well
taking a look at it
r
That’s reassuring 😄
thank you
f
Copy code
const api = new ApiGatewayV1Api(this, 'CustFeedbackApi', {
      routes: {
        'POST /save': {
          function: 'src/handler/saveFeedbackHandler.handleSaveFeedback',
          methodOptions: {
            authorizationType: AuthorizationType.NONE,
          },
        },
        'GET /retrieve': {
          function:
            'src/handler/retrieveFeedbackHandler.handleRetrieveFeedback',
          methodOptions: {
            authorizer: authorizer,
            authorizationType: AuthorizationType.CUSTOM,
          },
        },
      },
    });
If u move the
defaultAuthorizer
into the
methodOptions
of the route that needs it, u can workaround it for now
I’m going to push out a fix for this in a bit
r
Thanks - I now get
Copy code
Error: There is already a Construct with name 'GET' in Resource [retrieve]
sorry, my bad
mistake elsewhere
f