Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

entire backend API Proxy feature #258

Closed
TylerShin opened this issue Dec 11, 2019 · 3 comments
Closed

entire backend API Proxy feature #258

TylerShin opened this issue Dec 11, 2019 · 3 comments

Comments

@TylerShin
Copy link

TylerShin commented Dec 11, 2019

When using serverless-next-js with Serverless Component, there isn't input for api gateway setting.

For example, when using the legacy serverless.yml, we can override current default api gateway like below example.

resources:
  Resources:    
    APIProxyResourceParent:
      Type: AWS::ApiGateway::Resource
      Properties:
        ParentId:
          Fn::GetAtt:
            - ApiGatewayRestApi
            - RootResourceId
        PathPart: api
        RestApiId:
          Ref: ApiGatewayRestApi
    APIProxyResource:
      Type: AWS::ApiGateway::Resource
      Properties:
        ParentId:
          Ref: APIProxyResourceParent
        PathPart: '{proxy+}'
        RestApiId:
          Ref: ApiGatewayRestApi
    APIProxyMethod:
      Type: AWS::ApiGateway::Method
      Properties:
        ResourceId:
          Ref: APIProxyResource
        RestApiId:
          Ref: ApiGatewayRestApi
        HttpMethod: ANY
        AuthorizationType: NONE
        RequestParameters:
         method.request.path.proxy: true
        Integration:
          IntegrationHttpMethod: any
          Type: HTTP_PROXY
          Uri: ${file(./env/${opt:stage}.yml):API_ENDPOINT}
          RequestParameters:
           integration.request.path.proxy: method.request.path.proxy
          IntegrationResponses:
            - StatusCode: 200

I know that I can handle each endpoint of API gateway inside of NextJS from v9. however, making all of the API endpoint seems to redundant and annoying.

Also NextJS official document saying we should implement these proxy behavior by making custom server(sth like express or custom routing for Now)

However, we couldn't use custom server with serverless-next.js.
So I think this feature should be handled by serverless-next.js.

is there any solution for the proxy feature?

@danielcondemarin
Copy link
Contributor

I believe this could be a feature made available via @barrysteyn 's proposal in #270.

I'm thinking of something like:

component: serverless-next.js
inputs:
 cloudfront: 
   origins:
     url: https://somebackend.com
     pathPatterns:
        /this/path/is/proxied: 
         ttl: 5
         ... # other inputs in https://github.com/serverless-components/aws-cloudfront

This allows for greater flexibility in the CloudFront distribution provisioned by the component.

@TylerShin
Copy link
Author

I believe this could be a feature made available via @barrysteyn 's proposal in #270.

I'm thinking of something like:

component: serverless-next.js
inputs:
 cloudfront: 
   origins:
     url: https://somebackend.com
     pathPatterns:
        /this/path/is/proxied: 
         ttl: 5
         ... # other inputs in https://github.com/serverless-components/aws-cloudfront

This allows for greater flexibility in the CloudFront distribution provisioned by the component.

awesome

@danielcondemarin
Copy link
Contributor

Closing, this was implemented in #376

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants