Redirect Url no longer using document path
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current behavior
When setting up the Auth in the swagger before version 9 it use to set the redirect url to the serverURL/SwaggerPath/oauth2-redirect.htm
Now is is returning to serverURL/oauth2-redirect.htm no matter what configuration changes I put in to tell it to use the path as /swagger
Minimum reproduction code
https://github.com/nestjs/swagger
Steps to reproduce
const swaggerConfig = new DocumentBuilder()
.addOAuth2(
{
type: ‘oauth2’,
flows: {
implicit: {
authorizationUrl: ${CONFIG.auth.authUrl}/authorize
,
tokenUrl: CONFIG.auth.audience,
scopes: CONFIG.auth.scope,
},
},
scheme: ‘bearer’,
bearerFormat: ‘JWT’,
in: ‘header’,
},
‘Authorization’,
)
.setTitle(‘API’)
.setBasePath(‘/’)
.setDescription(‘The API description’)
.setVersion(‘1.0’)
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup('', app, document, {
swaggerOptions: {
baseUrl: '/',
showCommonExtensions: true,
filter: true,
persistAuthorization: false,
displayRequestDuration: true,
tryItOutEnabled: true,
tagsSorter: 'alpha',
operationsSorter: 'alpha',
// oauth2RedirectUrl: `http://localhost:3000/swagger/oauth2-redirect.html`,
},
initOAuth: { clientId: CONFIG.auth.clientId, scopes: CONFIG.auth.scope },
});
Expected behavior
Should be including the path in the url
Package version
6.0.5
NestJS version
9.0.8
Node.js version
16.13.1
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@flamewow would you like to look into this issue? Not sure if there were any breaking changes regarding OAuth flow
@DanielAeon, @rghoshfinaxys can you please check by opening the swagger URL with a slash at the end? e.g. your swagger URL is HTTP://localhost:3000/api-docs, try opening HTTP://localhost:3000/api-docs/ and see if you’ll get different results