Skip to content

HubSpot Serverless Functions not passing correct status codes during local development #95

@noerbot

Description

@noerbot

We set up some serverless functions following the example from this repo, but when I test a React module that uses one of our serverless functions locally via npm start, it always seems to receive a 200 OK status code even when the serverless function returns a 400 or 404.

You can see in the serverless logs that it's returning the correct status code:
image

But I always receive a 200 status code locally:
image

Based on the output in my terminal, it looks like these requests are running through a proxy:

attempting to proxy a POST serverless request to domain: 46512223.hs-sites.com for resource: /hs/serverless/create-user ...

I'm guessing that the proxy is just incorrectly converting everything to 200 for some reason. This makes building error handling for specific status codes very difficult, as I can't test the results locally. Even when I use the http://hslocal.net:3000/proxy?page= approach using a published page that includes my module, the same issue occurs.

The only way I can test status codes currently is if I deploy everything to Hubspot, but that's a super clunky DX.

Hoping someone can help! Thanks!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions