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.

[ktor-client-js] Ktor's User-Agent breaks CORS policy in a browser

See original GitHub issue

ktor-client-core-js 1.3.0-rc

I’m using ktor client in a browser to network requests (obviously), but something recently changed and now ktor provides default user-agent in case the developer himself didn’t. That ruins in browser. User-Agent header marks request as non-simple and browser performs cors-preflight request first, then rejects original request because User-Agent not allowed header for that server (and particularly any other server).

The worst moment I can not override that behavior and delete User-Agent header from request as this check performs on later stage inside of engine, so no any workarounds for me 😦.

Screenshot from 2019-12-28 01-01-13 Screenshot from 2019-12-28 01-00-47

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
e5lcommented, Jan 28, 2020

Fix in master

1reaction
Prototikcommented, Dec 29, 2019

Derp, chromium just ignores ktor’s user-agent and sends their own in place. Seems ktor’s user-agent completely useless in a browser.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CORS - Ktor
By default, browsers don't send credential information (such as cookies or authentication information) with cross-origin requests. To allow ...
Read more >
CORS pre-flight comes back with Access-Control-Allow-Origin ...
We have been noticing the same issue, where the server is sending the correct CORS headers, but the browser fails because it thinks...
Read more >
3 Ways to Fix the CORS Error — and How the Access-Control ...
If the frontend domain does not match the value, the browser raises the red flag and blocks the API request with the CORS...
Read more >
CORS errors - HTTP - MDN Web Docs - Mozilla
If the CORS configuration isn't setup correctly, the browser console will present an error like "Cross-Origin Request Blocked: The Same Origin ...
Read more >
User-Agent header disallowed via 'Access-Control-Allow ...
Platform: API Browser: Firefox 87.0 URLs of any relevant ... to header 'Access-Control-Allow-Headers' from CORS preflight response).
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