Reputation: 96
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.
Upvotes: 3
Views: 381
Reputation: 106
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!
Upvotes: 3
Reputation: 634
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.
Upvotes: 1