Search code examples
reactjscurlfetchgoogle-container-registry

Getting a list of Containers from GCR


I can currently use curl -u "oauth2accesstoken:token-value" https://gcr.io/v2/_catalog to fetch the list of containers in my registry, is there a way to do this through a web app?

I have tried using fetch('https://us.gcr.io/v2/_catalog',{method:'GET', headers:header }).then(res=>console.log(res)).catch(err=>console.log(err)); but keep getting 405 CORS error. Am I doing someting wrong or is this just impossible?

My header is header.set('Authorization', 'Basic ' + btoa(username + ":" + password));


Solution

  • So I got it working by setting up a proxy server using ExpressJs which made a HTTP call to the us.gcr.io. Then, I made a call from my react app to the express app and was able to get the data :)