Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request forbidden while fetching feature flag from gitlab to react application

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.

like image 581
Nikhil Avatar asked Dec 22 '25 09:12

Nikhil


2 Answers

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!

like image 146
user2652343 Avatar answered Dec 24 '25 00:12

user2652343


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.

like image 34
Saba Shavidze Avatar answered Dec 24 '25 00:12

Saba Shavidze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!