Merge pull request #1299 from sharelatex/spd-redirect-bypass-header

Add support for header to allow bypass of redirects

GitOrigin-RevId: 2d40c51c23809c19f0a053093e8ee0719a0190e2
This commit is contained in:
Simon Detheridge 2018-12-19 15:47:01 +00:00 committed by sharelatex
parent 366dbbd54f
commit b0b87a7b6e
2 changed files with 7 additions and 0 deletions

View file

@ -11,6 +11,7 @@ module.exports = RedirectManager =
createRedirect: (target) ->
(req, res, next) ->
return next() if req.headers?['x-skip-redirects']?
code = 302
if typeof target is 'string'
url = target

View file

@ -33,6 +33,12 @@ describe "RedirectUrls", ->
it 'redirects with query params', (done) ->
assertRedirect 'get', '/redirect/qs?foo=bar&baz[]=qux1&baz[]=qux2', 302, '/destination/qs?foo=bar&baz[]=qux1&baz[]=qux2', done
it "skips redirects if the 'skip-redirects' header is set", (done) ->
request.get {url: '/redirect/one', headers: {'x-skip-redirects': 'true'}}, (error, response) ->
should.not.exist error
response.statusCode.should.equal 404
done()
it 'redirects to /sign_in_to_v1 with authWithV1 setting', (done) ->
assertRedirect(
'get',