Electron axios post to oauth/token CORS problem

Posted 1 year ago by turkalicious

Hello all,

I've came across many topics about CORS issues here. I've been very hesitant to open another one myself but it has been hours and I still have not figured out a way. Desperate times...

axios.post(LOGIN_URL, creds, { headers: { 'Access-Control-Allow-Origin': '*' } })
      .then((response) => {
        localStorage.setItem('id_token', response.data.id_token);
        localStorage.setItem('access_token', response.data.access_token);

        this.user.authenticated = true;

        // Redirect to a specified route
        if (redirect) {
      }).catch((err) => {
        context.error = err;

is my post request and my credentials that I sent to are below

methods: {
      submit() {
        if (this.$refs.form.validate()) {
          const credentials = new FormData();
          credentials.append('username', this.username);
          credentials.append('password', this.password);
          credentials.append('grant_type', 'password');
          credentials.append('client_id', '5');
          credentials.append('client_secret', 'hvthW9MsfNnDSBqmVlBsb4oTwukPpli0puMZ4QH4');
          credentials.append('scope', ''); 
          auth.login(this, credentials, 'home-view');
      clear() {

Below is the full error in chrome console. I guess postman is not bound by CORS because I get my tokens from that

XMLHttpRequest cannot load http://newods.app/oauth/token. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9080' is therefore not allowed access.

I greatly appreciate any help. Thank you!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.