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.

problems with redirect in safari

See original GitHub issue

I have a strage problem on Safari where fetch follows the first redirect, but not the second one (see wireshark log below). On chrome and firefox (native fetch) this works as expected. The simplified flow is:

-> POST on /login
<- 302 found redirect to /
-> OPTIONS
<- 204
-> GET /
-> 302 found redirect to /build/allinOne/lims/lims.html

- fetch ends with error: TypeError: Network request failed

on chrome and ff instead of the error fetch issues a

GET  /build/allinOne/lims/lims.html

from where on everything succeeds

The fetch call is:

fetch(getLimsLogin(), {
            method: 'post',
            body: formData,
            credentials: 'include',
            redirect:'follow', 
            follow:20 
        })

Any Idea what can be wrong?

Thanks Ognian

POST /login HTTP/1.1
Host: localhost:3000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryuZkJrVCuSqoVuZhK
Origin: http://localhost:3100
Cookie: __utma=111872281.885784303.1429298870.1429298870.1429298870.1; connect.sid=s%3AT-1T4jDYXaItMZ91_Lw1bjnhIoxlKb-e.Dweqx3eWKgx%2BxWNfCHkTRi5axLKsWy8R5T5AdZaDXo0
Content-Length: 240
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
Referer: http://localhost:3100/index.html
Accept-Language: de-de
Accept-Encoding: gzip, deflate

------WebKitFormBoundaryuZkJrVCuSqoVuZhK
Content-Disposition: form-data; name="username"

ogi
------WebKitFormBoundaryuZkJrVCuSqoVuZhK
Content-Disposition: form-data; name="password"

ogi
------WebKitFormBoundaryuZkJrVCuSqoVuZhK--
HTTP/1.1 302 Found
Vary: X-HTTP-Method-Override, Origin, Accept
Access-Control-Allow-Origin: http://localhost:3100
Access-Control-Allow-Credentials: true
Location: /
Content-Type: text/plain; charset=utf-8
Content-Length: 23
Date: Sat, 28 Nov 2015 13:15:20 GMT
Connection: keep-alive

Found. Redirecting to /
OPTIONS / HTTP/1.1
Host: localhost:3000
Origin: http://localhost:3100
Access-Control-Request-Method: GET
Content-Length: 0
Access-Control-Request-Headers: accept-encoding, origin, accept-language
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
Referer: http://localhost:3100/index.html
Accept-Language: de-de
Accept-Encoding: gzip, deflate

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: http://localhost:3100
Vary: Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
Access-Control-Allow-Headers: accept-encoding, origin, accept-language
set-cookie: connect.sid=s%3Al9Hrf_9RmZCW_Q7cMTw8gvWqSnR24sZr.pxwsLiQQ7UZpQTgZWt69Qyc6x1tKXRpeevwW4czwyhY; Path=/; Expires=Sat, 28 Nov 2015 13:45:20 GMT; HttpOnly
Date: Sat, 28 Nov 2015 13:15:20 GMT
Connection: keep-alive

GET / HTTP/1.1
Host: localhost:3000
Origin: http://localhost:3100
Cookie: __utma=111872281.885784303.1429298870.1429298870.1429298870.1; connect.sid=s%3AT-1T4jDYXaItMZ91_Lw1bjnhIoxlKb-e.Dweqx3eWKgx%2BxWNfCHkTRi5axLKsWy8R5T5AdZaDXo0
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
Accept-Language: de-de
Referer: http://localhost:3100/index.html
Accept-Encoding: gzip, deflate

HTTP/1.1 302 Found
Access-Control-Allow-Origin: http://localhost:3100
Vary: Origin, Accept
Access-Control-Allow-Credentials: true
Location: /build/allinOne/lims/lims.html
Content-Type: text/plain; charset=utf-8
Content-Length: 52
Date: Sat, 28 Nov 2015 13:15:20 GMT
Connection: keep-alive

Found. Redirecting to /build/allinOne/lims/lims.html

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cancan101commented, Jun 29, 2016

I found this webkit issue : https://bugs.webkit.org/show_bug.cgi?id=57600. It’s marked fixed but I think this issue remains.

0reactions
Ogniancommented, Nov 30, 2015

Ok, I see, so this is indeed a Safari problem… I will need a different login api. Thanks Ognian

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve the too many redirects error on Safari? – Support
Open Safari · Click on “Safari” at the top left of your screen · Click on “Preferences…” · Click on the “Privacy” tab...
Read more >
How to Fix: Safari too many redirects occurred? - BrowserHow
If a site is unable to resolve and redirecting to itself, we encounter 'too many redirect' errors in Safari. In most cases it's...
Read more >
Safari Cannot Open The Page Because Too ... - macReports
Fix iOS and iPadOS redirects error · Tap Settings. · Tap Safari. · Scroll down and tap Advanced. · Tap Website Data. ·...
Read more >
3 ways to solve iPhone “Could not open the page, too many ...
3 ways to solve iPhone “Could not open the page, too many redirects” · Press and hold (aka 'long press') the Tabs button...
Read more >
"too many redirects occurred" message add…
Go to Settings > Safari > Block All Cookes, and make sure that's turned off. Then using Safari navigate to the gmail website...
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