Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greedy Proxy Path Does Not Work Locally #1037

Closed
metaskills opened this issue Mar 3, 2019 · 5 comments
Closed

Greedy Proxy Path Does Not Work Locally #1037

metaskills opened this issue Mar 3, 2019 · 5 comments

Comments

@metaskills
Copy link
Contributor

metaskills commented Mar 3, 2019

Description

Can not use greedy proxy path variable in local SAM server

Steps to reproduce

Using something like this template.yaml.

  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      DefinitionBody:
        swagger: 2.0
        info: { title: !Ref 'AWS::StackName' }
        basePath: '/'
        schemes: [ 'https' ]
        paths:
          /:
            get:
              x-amazon-apigateway-integration:
                uri:
                  Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}:live/invocations
                httpMethod: POST
                type: aws_proxy
          /{proxy+}:
            x-amazon-apigateway-any-method:
              parameters:
                - name: proxy
                  in: path
                  required: true
                  type: string
              x-amazon-apigateway-integration:
                uri:
                  Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}:live/invocations
                httpMethod: POST
                type: aws_proxy

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: .
      Handler: app.handler
      Runtime: ruby2.5
      MemorySize: 512
      Timeout: 10
      Events:
        Root:
          Type: Api
          Properties:
            Path: /
            Method: GET
            RestApiId: !Ref MyApi
        All:
          Type: Api
          Properties:
            Path: /{proxy+}
            Method: ANY
            RestApiId: !Ref MyApi

And then using sam local start-api

Observed result

Any root / request works, but requesting a path like /foo/bar results in.

2019-03-03 10:59:10 127.0.0.1 - - [03/Mar/2019 10:59:10] "GET /foo/bar HTTP/1.1" 403 -

Expected result

Building and deploying to AWS works. Can it work locally?

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac/Darwin
  2. sam --version: SAM CLI, version 0.11.0
@metaskills
Copy link
Contributor Author

FWIW, I've been working around this by using /app/{proxy+}. Seem SAM needs some sort of anchor in the path to help it along.

@metaskills
Copy link
Contributor Author

I also felt this was a little similar to #434 but I am not using any sort of builder, just raw SAM. Have not tested if this is specific to the Ruby runtime either.

@jfuss
Copy link
Contributor

jfuss commented Mar 5, 2019

@metaskills Thanks for this issue. I think this is similar to #437, if not the same issue. If you agree, I would prefer to close this one and track with #437.

@metaskills
Copy link
Contributor Author

Oh, I do think it might be. Will watch that one to see. Thanks! Closing this one now.

@prcongithub
Copy link

How can someone test this locally without support for /{proxy+}?

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

No branches or pull requests

3 participants