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.
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.