feat(examples): add web app calling an API example - #14
Merged
Merged
Conversation
…urce server The two Auth0 SDKs both augment the global Express.Request.auth0 type with incompatible shapes, so a web app (@auth0/auth0-express) and a resource server (@auth0/auth0-express-api) cannot share one tsc compilation. Instead of bundling the API, this example calls the existing example-express-api over HTTP. Adds a PORT override to example-express-api so it can run on 3001 alongside this app.
Piyush-85
reviewed
Jun 29, 2026
…block ts-node is not used by any script (start/build/test use tsx/tsc/vitest) and the ts-node tsconfig key is read by nothing. Per PR review feedback.
frederikprijck
force-pushed
the
example/web-call-api
branch
from
June 29, 2026 10:59
0a241dc to
ea9aa16
Compare
Piyush-85
approved these changes
Jun 29, 2026
frederikprijck
added a commit
that referenced
this pull request
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new self-contained example,
example-express-web-call-api, demonstrating how to use@auth0/auth0-expressto:audience, andreq.auth0.client.getAccessToken()and call a separate resource server on the user's behalf with aBearertoken.The resource server is the existing
examples/example-express-api(protected by@auth0/auth0-express-api), run as a separate service.example-express-apigains a backward-compatiblePORTenv override so it can run on3001alongside this web app on3000.Tests
src/index.spec.tsfollows the existingexample-express-mcdpattern (MSW + supertest). It mocks Auth0 discovery, JWKS, and the token endpoint (signing real RS256 JWTs withjose) and the downstream API, then drives a full mocked login (/auth/login→/auth/callback) and asserts:audience,/call-apiforwards the access token and renders the API response,/call-apiredirects to login without a session.CI
Adds a
Web App Calling an APIjob to.github/workflows/examples.ymlrunningbuild+test:ci, mirroring the other per-example jobs.Verification
npm run build -w @auth0/auth0-express && npm run build -w example-express-web-call-api && npm run test:ci -w example-express-web-call-api— build clean, 3/3 tests passing.