Giter Club home page Giter Club logo

Comments (5)

aulonm avatar aulonm commented on June 10, 2024 1

Same problem here. Getting invalid token: expected a different token type for this endpoint when doing this:

const defs = await getDefinitions({
  appName: 'xx',
  token: process.env.UNLEASH_SERVER_API_TOKEN,
  url: 'hardcoded url string'
})

but doing

const defs = await getDefinitions({
  appName: 'xx',
})

works

from unleash-client-nextjs.

Tymek avatar Tymek commented on June 10, 2024 1

url parameter expects different value from UNLEASH_SERVER_API_URL. For getDefinitions you need to provide full path to the endpoint (usually ending with /api/client/features) and server API URL points to Unleash instance (/api).

Relevant source:

* If you provide `url` in the config parameter, it should be a full endpoint path:
* @example getDefinitions({ url: `http://localhost:4242/api/client/features` })

And tested here: https://github.com/Unleash/unleash-client-nextjs/blob/main/lib/src/getDefinitions.test.ts#L116-L123C6

I can't reproduce this issue. Please reopen with reproducible steps if it still occurs.

from unleash-client-nextjs.

Tymek avatar Tymek commented on June 10, 2024

You need CLIENT token type for backend use. Not FRONTEND token. Also make sure your URL is configured according to documentation.

https://github.com/Unleash/unleash-client-nextjs#environment-variables
https://docs.getunleash.io/reference/api-tokens-and-client-keys#client-tokens

Does this solve your issue?

from unleash-client-nextjs.

hellonathanchung avatar hellonathanchung commented on June 10, 2024

When using the token/url in a .env it works fine. When trying to pass it into getDefinitions manually, that's when it seems to break.

from unleash-client-nextjs.

mltsy avatar mltsy commented on June 10, 2024

This helped, thanks!

I was having the same problem, because I didn't realize I needed to add /client/features if providing the url as an option rather than in an env variable (I assumed they'd be the same, since they're both called "URL". The configuration options would be a nice thing to document in the README, though I see it is JSDoc'd which would have been helpful, had I read those!

Is there any reason they are not treated the same? (that is, why not allow just the API URL for both, and have getDefinitions append /client/features as needed per its implementation?)

from unleash-client-nextjs.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.