Skip to content

Unable to change server. #921

Open
Open

Description

@codiophile

I am trying to use this: https://orkadocs.macstadium.com/reference/listvms

There isn't a public orka cluster, so the URL you need to use is your own private one for your own cluster. In the docs they are simply using example.com as an example. On the right, you can get it to generate code for you in different languages. When you select Node, it suggests that you use this library to generate a library for the API. I did that, but it doesn't work, because it is trying to send the requests to example.com. I checked the docs on how to change the server, but it doesn't seem to be working. Here's the code:

const orkaConfig = require("../../../config/orka.json")
const secrets = require("../../secrets")
const orka = require("@api/orka")

async function main() {
    console.log(orkaConfig.url)
    orka.server(orkaConfig.url)
    orka.auth(secrets.orkaId)
    await orka.listVMs({namespace: 'orka-default'})
        .then(({ data }) => console.log(data))
        .catch(err => {
            console.log(err.res.url)
            console.error(err)
        });
}

This prints:

https://my.orka.domain
https://example.com/api/v1/namespaces/orka-default/vms

Followed by the error message. I'm clearly passing the correct URL to orka.server(), but as you can see, it makes no difference and it keeps using example.com. This seems like a bug to me, as I seem to be doing everything in accordance with the documentation. I'm using version 6.1.2 and ideally this should be fixed and a new version released, but if there are any workarounds in the meantime, please let me know.

Activity

  1. davidguttman commented on Sep 11, 2024

    @davidguttman

    Running into this as well.

  2. DiogoRNeves commented on Dec 11, 2024

    @DiogoRNeves

    Also running into this. As far as I could check, the prepareServer function in api/packages/core/src/lib
    /prepareServer.ts doesn't find the configured server on the api spec, so it just ignores and the default from the oas library is used (example.com).

    I've manage to work around it by adding a key to the openapi.js file, even after the generation has been done, but this is not ideal: { ... "servers": [{"url": "https://my.base.url"}] }

  3. sigmachirality commented on Jan 6, 2025

    @sigmachirality

    Running into this as well, I agree that .server should probably just be able to override the base path url without any checks

  4. sigmachirality commented on Jan 6, 2025

    @sigmachirality

    You can discourage it via interface design (i.e., similar to dangerouslySetInnerHtml for react), but i think it is an option that should be given to the end user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions