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

feat: Add edge compatibility for custom frameworks and Next.JS #918

Merged

Conversation

deepjyoti30Alt
Copy link
Contributor

Summary of change

This PR adds fixes for various things that break when running this SDK with next.js on edge runtime.

Related issues

Test Plan

Testing with NextJS app router in edge runtime:

  1. Setup the example app from the repo
  2. Make all the server code use edge runtime by adding export const runtime = "edge"; to the top of the file.
  3. Run npm run build or npm run dev (live server)
  4. Both working without errors would indicate that the fix is working

Testing with NextJS pages router in edge runtime

  1. Setup the example next app using pages
  2. Make all the server code use edge runtime by adding export const runtime = "edge"; to the top of the file.
  3. Run npm run build or npm run dev (live server)
  4. Both working without errors would indicate that the fix is working

Test with express to confirm that inflate works with different compression methods:

  1. Create a demo BE app with express
  2. Inflate should work with br, gzip and deflate.
  3. Create a JSON file with the body, call it body.json.
  4. Create compressed versions using one of the following:
# For gzip
gzip -c body.json > body.gz

# For brotli
brotli -o body.br body.json
  1. Run cURL request with the created body:
# For gzip
curl -v -i -X POST http://localhost:3001/auth/signin -H 'Content-Encoding: gzip' --data-binary @body.gz

# For brotli
curl -v -i -X POST http://localhost:3001/auth/signin -H 'Content-Encoding: br' --data-binary @body.br
  1. Request should succeed successfully in order for the test to be successful.

Documentation changes

(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)

Checklist for important updates

  • Changelog has been updated
  • coreDriverInterfaceSupported.json file has been updated (if needed)
    • Along with the associated array in lib/ts/version.ts
  • frontendDriverInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In package.json
    • In package-lock.json
    • In lib/ts/version.ts
  • Had run npm run build-pretty
  • Had installed and ran the pre-commit hook
  • If new thirdparty provider is added,
    • update switch statement in recipe/thirdparty/providers/configUtils.ts file, createProvider function.
    • add an icon on the user management dashboard.
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.
  • If have added a new web framework, update the add-ts-no-check.js file to include that
  • If added a new recipe / api interface, then make sure that the implementation of it uses NON arrow functions only (like someFunc: function () {..}).
  • If added a new recipe, then make sure to expose it inside the recipe folder present in the root of this repo. We also need to expose its types.
  • If added a new entry point, then make sure that it is importable by adding it to the exports in package.json

@deepjyoti30Alt deepjyoti30Alt changed the title [WIP] Add edge compatibility for NextJS Add edge compatibility for NextJS Aug 30, 2024
Copy link

netlify bot commented Aug 30, 2024

Deploy Preview for precious-marshmallow-968a81 failed.

Name Link
🔨 Latest commit 58ab0e5
🔍 Latest deploy log https://app.netlify.com/sites/precious-marshmallow-968a81/deploys/66d8a6b8ed54fb0009f350bc

Copy link

netlify bot commented Aug 30, 2024

Deploy Preview for astounding-pegasus-21c111 failed.

Name Link
🔨 Latest commit 58ab0e5
🔍 Latest deploy log https://app.netlify.com/sites/astounding-pegasus-21c111/deploys/66d8a6b87ebe9d0008adf7c2

lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
.github/workflows/test-cf-worker-next.yml Outdated Show resolved Hide resolved
.github/workflows/test-cf-worker-next.yml Show resolved Hide resolved
.github/workflows/test-cf-worker-next.yml Outdated Show resolved Hide resolved
.github/workflows/test-cf-worker-next.yml Outdated Show resolved Hide resolved
lib/ts/framework/awsLambda/framework.ts Outdated Show resolved Hide resolved
lib/ts/framework/loopback/framework.ts Outdated Show resolved Hide resolved
lib/ts/framework/utils.ts Outdated Show resolved Hide resolved
test/framework/utils.test.js Outdated Show resolved Hide resolved
@deepjyoti30Alt deepjyoti30Alt force-pushed the feat/edge-compatibility-next branch from ec62f8c to 2f2fb62 Compare September 4, 2024 18:27
* Add init support for testing hono deployments on CF with edge

* Fix the directory path in hono workflow

* Fix the deploy command

* Fix tests to use assert instead

* Remove unused build command

* Update hono edge tests to test session endpoint as well

* Update README to contain proper details

* Drop brotli decompression support

* Remove brotli as a dependency
@rishabhpoddar rishabhpoddar changed the base branch from master to 20.0 September 5, 2024 06:00
examples/cloudflare-workers/with-be-emailpassword/index.ts Outdated Show resolved Hide resolved
lib/ts/framework/constants.ts Outdated Show resolved Hide resolved
lib/ts/framework/custom/nodeHeaders.ts Outdated Show resolved Hide resolved
@deepjyoti30Alt deepjyoti30Alt changed the title Add edge compatibility for NextJS feat: Add edge compatibility without nodejs_compat flag Sep 5, 2024
@deepjyoti30Alt deepjyoti30Alt changed the title feat: Add edge compatibility without nodejs_compat flag feat: Add edge compatibility for custom frameworks and Next.JS Sep 5, 2024
@porcellus porcellus changed the base branch from 20.0 to 20.1 September 9, 2024 14:41
@porcellus porcellus merged commit 8fabd09 into supertokens:20.1 Sep 9, 2024
8 of 11 checks passed
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

Successfully merging this pull request may close these issues.

3 participants