Repository navigation
fix(#54): gate Swagger UI behind non-production, pin version, add SRI - #147
Merged
Busiii-adetiba merged 1 commit intoOct 20, 2026
Conversation
…on, add SRI - Conditionally register GET /docs only when NODE_ENV !== 'production'. /openapi.json and /docs/json remain available in all environments. - Pin swagger-ui-dist to 5.34.0 (exact semver, no floating major). - Add integrity (sha384) and crossorigin='anonymous' attributes to both the <link> and <script> tags so browsers enforce SRI on CDN assets. - Add comments with instructions for recomputing hashes on version bumps. - New docs.production.test.ts: verifies /docs → 404 and /openapi.json → 200 with NODE_ENV=production (separate file so the vi.mock hoist applies to the module-level if-gate in docs.ts). - Updated docs.test.ts: adds four new assertions for integrity attr, crossorigin attr, and pinned semver; existing tests all preserved.
|
@euniceamoni is attempting to deploy a commit to the work Team on Vercel. A member of the Team first needs to authorize it. |
|
@euniceamoni Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Fixes #54.
Changes
src/routes/docs.tsGET /docsis now only registered whenNODE_ENV !== 'production'./openapi.jsonand/docs/jsonremain available in all environments.swagger-ui-distto exact version5.34.0(no more floating@5).integrity="sha384-…"andcrossorigin="anonymous"to both the<link>and<script>tags so browsers enforce SRI on CDN assets.src/app.tsdocsRouter.src/routes/docs.test.tsvi.mockso the module-levelif-gate evaluates withNODE_ENV="test".crossorigin="anonymous"on both assets, pinned semver format.src/routes/docs.production.test.ts(new)vi.mockhoists beforedocs.tsloads withNODE_ENV="production".GET /docs→ 404,GET /openapi.json→ 200,GET /docs/json→ 200.Tests
12/12 pass across both test files.
Acceptance criteria
/docsreturns 404 whenNODE_ENV=productionintegrityattribute for each asset closes Swagger UI is served in every environment, and its CDN assets are unpinned #54