Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS Issue for Unleash admin API from vue webapp #6923

Open
pp24-25 opened this issue Apr 24, 2024 · 1 comment
Open

CORS Issue for Unleash admin API from vue webapp #6923

pp24-25 opened this issue Apr 24, 2024 · 1 comment

Comments

@pp24-25
Copy link

pp24-25 commented Apr 24, 2024

Describe the bug

I am trying to unleash api in vue app directly to manipulate the underline unleash instance and I am facing cors error. Took this example from unleash documentation .

let config = {
    method: 'get',
    maxBodyLength: Infinity,
    url: 'http://unleash.example.com/api/admin/search/features',
    headers: { 
      'Accept': 'application/json', 
      'Authorization': 'user:token',
      'Content-Type': 'application/json'
    }
  };
    const response = await axios(config)
    .then((response)=> {
      console.log(response)
      return response.data
    })
    .catch((error) => {
      return { data: error.response.data }
    })

Error : - Access to XMLHttpRequest at 'http://unleash.example.com/api/admin/search/features' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

Steps to reproduce the bug

No response

Expected behavior

We tested via curl in postman we were able to get response so expected this javascript code also to work.

Logs, error output, etc.

No response

Screenshots

No response

Additional context

No response

Unleash version

5.9.6

Subscription type

Open source

Hosting type

Self-hosted

SDK information (language and version)

no SDK being used

@pp24-25 pp24-25 added the bug label Apr 24, 2024
@sighphyre
Copy link
Member

So we don't support this at the moment, the easiest way to solve this for your needs is to spin up a proxy to handle CORS, something like Vercel might help out here.

Unleash is OSS so we'd be open to looking at a PR or providing guidance if you'd want to take a stab at fixing this!

@ivarconr ivarconr added enhancement and removed bug labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For later
Development

No branches or pull requests

3 participants