supertokens-node icon indicating copy to clipboard operation
supertokens-node copied to clipboard

Create a serverless.com framework integration

Open rishabhpoddar opened this issue 4 years ago • 2 comments

  • [ ] Able to add auth endpoint automatically
  • [ ] Able to do CORS and gateway config automatically
  • [ ] No need to create explicit express app in user's API endpoints for session management.

See https://medium.com/swlh/how-to-actually-develop-test-and-publish-your-first-plugin-for-the-serverless-framework-337665eb66fa

rishabhpoddar avatar May 04 '21 08:05 rishabhpoddar

Hi!

I want to share my experience in making this library work inside a Cloudflare Worker.

  1. Add node_compat = true to the wrangler.toml config file.
  2. Commented out assertThatBodyParserHasBeenUsedForExpressLikeRequest from lib/build/framework/utils.js as the file imports http package from node which is not supported by Worker
  3. I've removed all import { URL } from "url" statements as URL class is native to Worker
  4. I've added the @vespaiach/axios-fetch-adapter package and adapter: fetchAdapter to all axios requests
  5. Created a WorkerRequest and WorkerResponse wrappers to pass to supertokens.middleware(...)

captainjapeng avatar Jun 07 '23 04:06 captainjapeng

I'm currently stuck at this point...

WARNING: known issue with `fetch()` requests to custom HTTPS ports in published Workers:
 - https://<REDACTED>.aws.supertokens.io:3573/apiversion - the custom port will be ignored when the 
Worker is published using the `wrangler publish` command.

captainjapeng avatar Jun 07 '23 05:06 captainjapeng