-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to access Swagger UI on non SSL Express server
- Loading branch information
Showing
2 changed files
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import express from 'express'; | ||
import helmet from 'helmet'; | ||
import swaggerUi from 'swagger-ui-express'; | ||
|
||
import servicesRouter from './services.js'; | ||
import specsRouter, { specs } from './specs.js'; | ||
|
||
const apiRouter = express.Router(); | ||
|
||
apiRouter.use('/specs', specsRouter); | ||
apiRouter.use('/docs', swaggerUi.serve); | ||
apiRouter.get('/docs', swaggerUi.setup(specs)); | ||
|
||
apiRouter.use(helmet()); // Register `helmet` after swaggerUi routes to ensure insecure requests won't be upgraded to secure requests for swaggerUI assets; see https://github.com/scottie1984/swagger-ui-express/issues/212#issuecomment-825803088 | ||
|
||
apiRouter.use('/specs', specsRouter); | ||
apiRouter.use('/services', servicesRouter); | ||
|
||
export default apiRouter; |
This file contains 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