I’m trying to configure a React application to leverage Gitlab’s feature flags integration and no matter what I do but I always get a 401 response from the server.
I’m configuring my client with the configuration data given in the “React proxy SDK” modal (i.e. API URL and Instance ID) and installed the React proxy SDK https://docs.getunleash.io/sdks/proxy-react.
I don’t really know what I have to put in appName. The configuration modal says that “Set the Unleash client application name to the name of the environment your application runs in…”. I have tried multiple possible values with no luck: dev, development, prod, production, etc…
At this point I doubt if its even possible to configure this in a Javascript/React application since all Unleash frontend clients uses Unleash Proxy and I doubt if the given url is a proxy url or not.
I actually ran into the same issue and then I noticed this from the Unleash documentation:
This library is meant to be used with the unleash-proxy. The proxy application layer will sit between your unleash instance and your client applications, and provides performance and security benefits. DO NOT TRY to connect this library directly to the unleash instance, as the datasets follow different formats because the proxy only returns evaluated toggle information.
Hi Ramon and thanks again for sharing your solution.
It definitely works! The only downside is that we would need as many proxies as projects so we will try another solution. We will see if it could be possible for each project’s backend to connect to gitlab and expose the feature flags via API endpoint.
Quick question: Where do you find the value for UNLEASH_API_TOKEN? I am using this directly from Gitlab and its not clear where to get this api token. Thanks!
@cvillanueva10 The UNLEASH_API_TOKEN would be your personal access token for Gitlab which can be obtains from: https://gitlab.com/-/profile/personal_access_tokens
In case you’re running a hosted version of Gitlab this would be <your-gitlab-domain>/-/profile/personal_access_tokens
When you create this access token make sure to add the scope api