amplify-education / serverless-domain-manager

Serverless plugin for managing custom domains with API Gateways.
MIT License
941 stars 232 forks source link

unable to set multiple segments in base path #582

Open ianzone opened 1 year ago

ianzone commented 1 year ago

Community Note

Bug Report

Error Description When set multiple segments in basePath, the api is recognized as V2, even though it's a rest api (V1).

Command Run sls deploy

Console Output

βœ– Stack meeting-dev failed to deploy (135s)
Environment: linux, node 18.16.0, framework 3.31.0 (local) 3.31.0v (global), plugin 6.2.3, SDK 4.3.2
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: V2 - Unable to create base path mapping for 'demo-service.tin.info':
Only REGIONAL domain names can be managed through the API Gateway V2 API. For EDGE domain names, please use the API Gateway V1 API. Also note that only REST APIs can be attached to EDGE domain names.
    at APIGatewayV2Wrapper.<anonymous> (/home/ian/acte/roomzz-v1/api/meeting/node_modules/.pnpm/serverless-domain-manager@7.0.4_serverless@3.31.0/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v2-wrapper.js:118:23)
    at Generator.throw (<anonymous>)
    at rejected (/home/ian/acte/roomzz-v1/api/meeting/node_modules/.pnpm/serverless-domain-manager@7.0.4_serverless@3.31.0/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v2-wrapper.js:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Domain Manager Configuration using serverless.ts

    customDomain: {
      // https://github.com/amplify-education/serverless-domain-manager
      domainName: '${param:domain}',
      certificateName: '${env:Certificate_Name}',
      basePath: 'meeting/${sls:stage}',
      autoDomain: true,
      preserveExternalPathMappings: true,
    },

Versions

rddimon commented 1 year ago

Hi @ianzone

The error says that you are using EDGE endpoint type. Could you please switch to the REGIONAL?

ianzone commented 1 year ago

but I am using the apigateway V1 and meant to use the EDGE endpoint

functions: {
api: {
handler: 'dist/api.handler',
events: [
{
http: {
method: 'ANY',
path: '/',
cors: true, // https://www.serverless.com/framework/docs/providers/aws/events/apigateway#enabling-cors
},
},
{
http: {
method: 'ANY',
path: '{proxy+}',
cors: true, // https://www.serverless.com/framework/docs/providers/aws/events/apigateway#enabling-cors
},
},
],
},