Following Express guide: "Missing Authentication Token" at Hello world?

Hello, I’m using the following guide to setup an express serverless app:

Unfortunately, it seems somewhat out of date (it’s not dated). Something is occurring where the middleware for app.get(’/’) works fine, but anything passed that returns this message:

{
  "message": "Missing authentication token."
}

I’m not sure what is going on. My index.js looks identical to that in the guide. I tried logging at the top of the body of each subsequent middleware function to see if they are even getting called, and it doesn’t appear that they are. I think this has something to do with the definitions for the routes in serverless.yml.

It does not seem to like this:

functions:

  app:
    handler: index.handler
    events:
      - http: ANY /
      - http: 'ANY {proxy+}'

Any pointers in the right direction would be so appreciated. Thanks.

Sorry. A little bit more patience would have led me to correct the error sooner. The guide showed the http event wrapped in a string, which is wrong. It would be nice if these articles accepted pull requests - that guide is full of errors.

What is the solution, can you elaborate?

The solution for me was that I was using curl to access my new API with something like:

curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/myfunc

but that uses GET by default, and I had configured my function to use POST. So I needed to run:

curl -X POST https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/myfunc

Then it worked (and i got an internal error) but that’s another issue. This “Missing authentication token.” is just a super bad error message. You have to configure each error message separately in API Gateway or else it uses the default.