Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong redirect #69

Closed
sjorsjes opened this issue May 11, 2018 · 2 comments
Closed

Wrong redirect #69

sjorsjes opened this issue May 11, 2018 · 2 comments

Comments

@sjorsjes
Copy link

sjorsjes commented May 11, 2018

v0.10.1 - There stil seems to be a bug when using routePrefix: '/' even after this fix (#65) from @allevo. It redirects the browser to index.html instead of http://domain/index.html

@allevo
Copy link
Member

allevo commented May 11, 2018

Hi!
sorry for the inconvenient.

With the following test, which redirection are you expecting ?

test('with routePrefix: \'/\' should redirect /', t => {
  t.plan(4)
  const fastify = Fastify()

  const opts = JSON.parse(JSON.stringify(swaggerInfo))
  opts.routePrefix = '/'
  fastify.register(fastifySwagger, opts)

  fastify.get('/foo', () => {})

  fastify.inject({
    method: 'GET',
    url: '/'
  }, (err, res) => {
    t.error(err)
    t.strictEqual(res.statusCode, 302)
    t.strictEqual(res.headers['location'], '????????????????')
    t.is(typeof res.payload, 'string')
  })
})

The current implementation (0.10.1) redirects to //index.html (with double slashes)

@sjorsjes
Copy link
Author

The current implementation forces my browser to go to ‘index.html’ instead of ‘domain/index.html’. The fix I suggested allows for a single slash and makes the browser go to the right path. You can test it by setting the ‘routePrefix’ option to ‘/‘

allevo added a commit that referenced this issue May 11, 2018
@allevo allevo closed this as completed in 46ae773 May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants