Search code examples
javascriptangularjsrestangular

Restangular XMLHTTPRequest cannot load, but browser show response


I'm using Restangular to consume some REST Api that I've built and I'm receiving a XMLHTTPRequest cannot load telling me that my origin is not allowed.

But when I look at the network section on browser inspector, the response is there with a 200(Ok) and when I send the request via Postman it works too.

Do I need to set something other than the baseUrl on Restangular to get this done right?

This is my headers:

response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers',
                     'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods',                                                                                                                                
                      'GET,PUT,POST,DELETE')

Solution

  • Answering my question!

    The problem was in my Flask app!

    The annotation @app.after_request wasn't working since I've changed to the factory app pattern.

    Now its working and I can continue writing the Angular side of the application.

    Thank you!