1

I have created a feature flag in gitlab. I need to fetch the value of that particular flag in my React application. I have written the below code, and the code generates the 403 Forbidden error. I have also checked the permission to the personal access token but still it says forbidden.

import axios from 'axios';

const data = async () => {
    const response = await axios.get('https://gitlab.com/api/v4/features', {
      headers: {
        'PRIVATE-TOKEN': '<MY_PERSONAL_ACCESS_TOKEN_HERE>',
      },
    });
    return response.data;
  };
  useEffect(() => {
    console.log(data());
  }, []);

I tried hitting the API through postman but still it results in generating the 403 forbidden error.

Nikhil
  • 56
  • 1
  • 9

2 Answers2

1

In order to use feature flags in gitlab together with a frontend SDK you will need to use the Unleash Proxy.

https://github.com/Unleash/unleash-proxy

Good luck!

0

Maybe you need to verify CORS configuration in Gitlab.Check if your GitLab instance has CORS (Cross-Origin Resource Sharing) properly configured to allow requests from your React application's domain. If CORS is not set up correctly, it can result in a "403 Forbidden" error.

Saba Shavidze
  • 604
  • 4
  • 14
  • We do not use self-hosted GitLab. From where can I configure the requests to be allowed, any idea regarding this? – Nikhil Jun 06 '23 at 09:47