0

So my problem is: I Have Lumen server on subdomain api.domain.com After sending ajax request from domain.com to api.domain.com:

$.ajax({
            url: 'https://api.domain.com/login',
            type: 'post',
            headers: {
                'Authorization': 'someJWTTOKEN'
                'Content-Type': 'application/json'
            },
            data: {},
            dataType: 'json',
            success: function(result) {
                console.log('result');
                console.log(result);
            },
            error: function(error) {
                console.log(error);
            }
        });

Now I get CORS error: enter image description here

But when I remove Header from ajax request, everything works fine.

This works great:

   $.ajax({
                url: 'https://api.domain.com/login',
                type: 'post',
                headers: {
                },
                data: {},
                dataType: 'json',
                success: function(result) {
                    console.log('result');
                    console.log(result);
                },
                error: function(error) {
                    console.log(error);
                }
            });
Peter Valek
  • 87
  • 1
  • 2
  • 11

1 Answers1

1

I had this problem connecting my React app to my Lumen API but solved it by using this PHP Package. In the README they explain how to configure the package with Lumen. Legit took me like 2 minutes.

Solomon Antoine
  • 554
  • 1
  • 7
  • 14