Skip to content

Unclear additions of slashes to request url when using client get/put/patch/head methods directly #2189

Open
@nickclassdojo

Description

@nickclassdojo

Description

When attempting to use a client's raw get/put/patch/head methods directly, sometimes it's desirable to do this with a URL that you are unaware of the structure for (such as if your server is giving you a url to make a call to retrieve information from S3). There is no official documentation on this, but the api makes it look like it may be possibl via:

  1. Pass {baseUrl: <your_url>, url: ''}
    OR
  2. Pass {baseUrl: '', url: <your_url>}

Neither of these work because:

  • If your url is an empty string, an automatic / gets appended to the end
  • If your baseUrl is an empty string, an automatic / gets prepended to the beginning

This makes it not possible to make a request where you want to take the whole url wholesale

Reproducible example or configuration

Using any generated client that has no config set
Using:
"@hey-api/client-fetch": "^0.10.1"
"@hey-api/openapi-ts": "^0.66.7",

import { createClient } from '@hey-api/client-fetch';
const client = createClient()
client.get({
    baseUrl: 'https://google.com?q=stuff',
    url:'',
  })

interceptors.request.use((config) => {
    console.log('url', config.url);
    return config
  });

See that the url has a traling slash, even though this would not be corrrect necessarily with query parameters

import { createClient } from '@hey-api/client-fetch';
const client = createClient()
client.get({
    baseUrl: ''
    url: 'https://google.com?q=stuff,',
  })

interceptors.request.use((config) => {
    console.log('url', config.url);
    return config
  });

See that the url has preceding slash

Is there a way to take the url wholesale and use it without adding slashes that isn't documented?

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't workingfeature 🚀New feature or requestprioritized 🚚This issue has been prioritized and will be worked on soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions