Repository navigation
feat(nextjs): serve the admin console from a Next.js application - #187
Merged
Merged
Conversation
Add createSeamlessConsoleProxy, a GET/HEAD route handler for app/console/[[...path]]/route.ts that proxies the dashboard SPA from the auth server, matching the Express and Fastify console proxies. The console parity scenarios now run against Next.js and Express. Closes #185
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
Closes #185.
Adds
createSeamlessConsoleProxyto@seamless-auth/nextjs, the counterpart of the Express and Fastify console proxies:Authorization), copiescontent-type,cache-control,etag, andlast-modifiedback, refuses encoded%2f/%5c, and never requests outside the console subtree. An unreachable upstream answers 502.RequestURL parser collapses..and%2e%2e, so a traversal shows up as a path outside the mount and gets a 400.GETandHEAD. Next.js answers 405 for methods the route does not export, so a write never reaches the handler. The handler still guards the method in case it is wired to another export.mountPathoption (default/console), because a route handler does not know where it is mounted. It must include any Next.jsbasePath.basePathkeeps the sibling meaning (the upstream subtree).Responseconstructor would throw, see fix(nextjs): send no body on a null-body status #181).Scope item 2 (CORS for a dashboard on another origin)
Not included. Same origin is documented as the only supported shape. A CORS mode would mean credentialed cross-origin requests to the cookie session routes, which needs its own design. If we want it, it should be a separate issue.
Tests
packages/nextjs/tests/parity.test.js: the Fastify console scenarios, plus the console root, run against Next.js and Express (status, body, content type, cache control, and upstream URLs must match). The "write is refused" scenario is left out because Next.js handles that before the handler runs.packages/nextjs/tests/consoleProxy.test.js: exported methods, HEAD, the response header allowlist, no forwarded credentials, null-body status,mountPathandbasePath, and paths outside the mount.pnpm build,pnpm test(core 314, express 190, nextjs 124, fastify 108), andpnpm check:types-currentall pass.Cross-repo
Once this ships, fells-code/seamless-cli#219 can offer
--admin=apifor the Next.js full-stack template.