firecamp-io / firecamp

VSCode for APIs, Postman Alternative.
https://firecamp.dev
317 stars 22 forks source link

not working location header redirect #180

Closed pavlikm closed 2 years ago

pavlikm commented 2 years ago

1. Describe the bug, what it is and what it should be (expected behavior)

when try to redirect with Location header, this redirect is not performed

2. To Reproduce

steps to reproduce the behavior:

  1. in Auth tab fill Auth Url: http://localhost:4000/not-working
  2. blank page is showed <-- should print 'it works'

3. screenshots/gif/video?

sample code:

const express = require('express')
const app = express()
const port = 4000

app.get('/works', (req, res) => {
    res.send('<script>window.location.href="http://localhost:4000/ok"</script>');
})
app.get('/not-working', (req, res) => {
    res.send('<script>window.location.href="http://localhost:4000/redirect-with-header"</script>');
})
app.get("/redirect-with-header", (req, res) => {
    res.location('http://localhost:4000/ok')
})

app.get('/ok', (req, res) => {
    res.send('it works');
})

app.listen(port, () => {
    console.log(`Example app listening at http://localhost:${port}`)
})

image

4. additional context

if you put http://localhost:4000/works, everything works good. In browser works both urls. For url http://localhost:4000/not-working I see 'it works' in chrome browser


platform (please complete the following information):
welcome[bot] commented 2 years ago

Welcome to the Firecamp! Thanks and congrats for opening your very first issue in Firecamp. Join the Discord community here https://discord.gg/8hRaqhK Hope you have a great time here :)

Nishchit14 commented 2 years ago

thanks for sharing info @pavlikm 👍

pranavwani commented 2 years ago

@pavlikm res.location only set the location header which does not redirect to the specified location. maybe res.redirect will help in that case in API: /redirect-with-header