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

fetch url now show the final url after all redirect #2520

Closed
fancy45daddy opened this issue Dec 13, 2023 · 7 comments · Fixed by #2716
Closed

fetch url now show the final url after all redirect #2520

fancy45daddy opened this issue Dec 13, 2023 · 7 comments · Fixed by #2716
Labels
bug Something isn't working

Comments

@fancy45daddy fancy45daddy added the bug Something isn't working label Dec 13, 2023
@KhafraDev
Copy link
Member

KhafraDev commented Dec 13, 2023

fetch will return the final redirect's url. If you can provide a minimal reproduction that doesn't use third party services I can look into it.

test code
import { once } from 'events'
import { createServer } from 'http'

const server = createServer((req, res) => {
  if (req.url === '/redirect') {
    res.writeHead(302, { Location: '/redirect2' })
    res.end()
    return
  }

  res.end('hello')
}).listen(0).unref()


await once(server, 'listening')

const r = await fetch(`http://localhost:${server.address().port}/redirect`)
console.log(r.url) // .../redirect2
server.close()

@KhafraDev
Copy link
Member

I'm sorry I can't help until there's a reproducible code example that doesn't use third party sites. Fetch by default will return the last redirect url.

@fancy45daddy
Copy link
Author

what reproducible code example you want?
I test the case both node-fetch curl and python aiohttp can go to the last redirect url but undici just hang at the first redirect url. Please help.

@Uzlopak
Copy link
Contributor

Uzlopak commented Feb 8, 2024

What does the spec say? What value should it have?

@mcollina
Copy link
Member

mcollina commented Feb 8, 2024

what reproducible code example you want?

Write the server needed to reproduce the behavior in Undici.

@Uzlopak
Copy link
Contributor

Uzlopak commented Feb 8, 2024

added a test case for this issue which proves, that the final url is set to the response.

#2716

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants