Open api post gives 403 with serverless-domain-manager

I have a test api with no authentication. Everything works with gets and using internal calls, but when I create usable endpoints I get 403 errors. Here are the urls that work (using httpie). I have included the get calls to show the endpoints do work.

http get https://9lu88q2p7i.execute-api.us-east-1.amazonaws.com/staging/test
http post https://9lu88q2p7i.execute-api.us-east-1.amazonaws.com/staging/test
http get https://staging.patternmaker.cc/api/test

The following call does not work

http post https://staging.patternmaker.cc/test

My serverless.yml looks like

service: reg-web
provider:
  name: aws
  runtime: nodejs6.10
  stage: staging
  region: us-east-1

functions:
  get_test:
    # handler: register.register
    handler: api.get_test
    events:
      - http:
          path: test
          method: get
          cors: true
  post_test:
    handler: api.post_test
    events:
      - http:
          path: test
          method: post
          cors: true
plugins:
  - serverless-webpack
  - serverless-domain-manager
custom:
  myStage: ${opt:stage, self:provider.stage} # myStage =  --stage CLI option || provider.stage
  webpackIncludeModules: true
  domain:
    staging: 'staging.patternmaker.cc'
    production: 'reg.patternmaker.cc'
  customDomain:
    domainName:  ${self:custom.domain.${opt:stage}} # 'reg.patternmaker.cc'
    basePath: 'api' # This will be prefixed to all routes
    stage: ${opt:stage} # ${self:provider.stage}
    createRoute53Record: true

Hey @gap, as I understand it, you’re including the api prefix to your routes from the basePath. Because of that, should your request be:

http post https://staging.patternmaker.cc/api/test

Note that I added api/ before test in the path.

Does that fix your problem?

1 Like

Yes it does. Silly typo on my part. Thanks!

1 Like