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: request to /example requests http://localhost/example

See original GitHub issue

Ktor Version and Engine Used (client or server and name) Ktor Client Common 1.3.1, in browser (JS)

Describe the bug request to /example requests http://localhost/example

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/Ribesg/Kita/tree/2c7941183ebcde1fc2193bd00a1bed53f1249b10 on a machine which can be reached from the network (a server)
    git clone https://github.com/Ribesg/Kita
    cd Kita
    git reset --hard 2c7941183ebcde1fc2193bd00a1bed53f1249b10
    
  2. Run ./runServer.sh
  3. Browse to https://yourserver:12345
  4. Try to login using whatever credentials (correct ones are admin/admin)
  5. See failing requests to https://localhost/api/auth/login instead of https://yourserver:12345/api/auth/login in the console

Expected behavior Requests should use the current location.origin when none is provided in the browser

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Benjoyocommented, Mar 6, 2022

Any updates? Still present in 1.6.7.

2reactions
Stexxecommented, Jun 24, 2021

I can still reproduce it using Ktor 1.6.0 when running a development server with the following code:

GlobalScope.launch {
     val client = HttpClient(Js)
     val r = client.get<String>("/example")
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Making requests | Ktor
Code example: client-configure-request ... The main way of making HTTP requests is the request function that can take a URL as a parameter....
Read more >
Creating a client application - Ktor
In this tutorial, we'll create a simple client application for sending a request and receiving a response. Prerequisites. Before starting this ...
Read more >
Handling requests - Ktor
This returns the ApplicationRequest instance and provides access to various request parameters. For example, the code snippet below shows ...
Read more >
Creating and configuring a client - Ktor
import io.ktor.client.engine.cio.* val client = HttpClient(CIO). In this example, we use the CIO engine. You can also omit an engine:.
Read more >
Creating HTTP APIs - Ktor
Website: Leave the default example.com value as a domain used to ... When a client makes such a request, content negotiation allows the ......
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