question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect Url no longer using document path

See original GitHub issue

Is 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:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Aug 11, 2022

@flamewow would you like to look into this issue? Not sure if there were any breaking changes regarding OAuth flow

0reactions
flamewowcommented, Aug 15, 2022

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

window.location.href doesn't redirect - Stack Overflow
It will run the code in the function and then submit the page instead of redirect. In this case change the type tag...
Read more >
The Ultimate Guide to Redirects: URL Redirections Explained
Redirects send users & search engines from one URL to another. Find out how to use each type here.
Read more >
How can I redirect and rewrite my URLs with an .htaccess file?
The first path to the old file must be a local UNIX path, NOT the full path. So, if the .htaccess file is...
Read more >
Redirections in HTTP - MDN Web Docs - Mozilla
These redirections are meant to last forever. They imply that the original URL should no longer be used, and replaced with the new...
Read more >
URL Redirects - Squarespace Help Center
To use a 301 redirect, the original URL can no longer exist, and the new one must exist. Ensure the old URL doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found