How to remove authorization header from request

Mr Smith

I'm using MEAN Stack User Registration and Login Example & Tutorial as the base for my app. It adds an auth header to every request in the run function:

$http.defaults.headers.common['Authorization'] = 'Bearer ' + $window.jwtToken;

I want to upload images to Cloudinary but I'm getting this error:

XMLHttpRequest cannot load https://api.cloudinary.com/v1_1/xxxx/upload. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

How can I remove this header specifically for requests to Cloudinary?

Muli Yulzary

You will require an interceptor that checks for the url of the request and clears the header if it matches. alternatively you can use the $http config parameter.

Using the parameter:

$http.post('https://api.cloudinary.com/v1_1/' + someId + '/upload', data, { headers: {} });

Using an interceptor:

.factory('cloudinaryInterceptor', function() {
 return {
  request: function(config){
   var authHeader = config.headers('authorization');
   //Check for the host
   var regex = /api\.cloudinary\.com/i;
   if(regex.test(config.url))
    //Detach the header
    delete config.headers.authorization;
   return config;
  }
 }
});

Remember to push the interceptor in the config phase

$httpProvider.interceptors.push('cloudinaryInterceptor');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can we remove "Authorization" Header from a 'HttpServletRequest'

From Dev

How to send Authorization header with a request in Swagger UI?

From Dev

'Authorization' header sent with request, but missing from apache_request_headers()

From Dev

How to remove header from AJAX call for a single request?

From Dev

How do I edit the authorization header of an HTTP GET request originating from a hyperlink (<a href> tag)

From Dev

.Net Windows webBrowser - how to extract authorization header from webBrowser response and send to another consecutive request?

From Dev

How to get value from header authorization bearer?

From Dev

How to fetch Authorization from page header?

From Dev

What is the proper way to grab Authorization header from controller request object?

From Dev

Swift 2 How do you add authorization header to POST request

From Dev

Swift 2 How do you add authorization header to POST request

From Dev

How to pass params and add authorization header in GET Request in Volley

From Dev

How to get code from Facebook Authorization request?

From Dev

Authorization header in Http Request in linkedin

From Dev

Request header field Authorization is not allowed

From Dev

How to remove (not modify) a request header in a Firefox addon?

From Dev

How to compute Basic Authorization header from username and password

From Dev

Authorization header missing in PHP POST request

From Dev

Guzzle HTTP - add Authorization header directly into request

From Dev

Authorization header not being sent in AJAX request

From Dev

angular $http GET request with authorization token header

From Dev

Sending Authorization Header with JWT in HTTP-Request

From Dev

Python requests: POST request dropping Authorization header

From Dev

Python POST request dropping Authorization header

From Dev

Python requests: POST request dropping Authorization header

From Dev

Why Authorization header is not send in API request in Angular?

From Dev

AFNetworking 2: Authorization header not included in request

From Dev

API Request with HTTP Authorization Header inside of componentDidMount

From Dev

Swagger Editor Not Passing Authorization in the Request Header

Related Related

  1. 1

    How can we remove "Authorization" Header from a 'HttpServletRequest'

  2. 2

    How to send Authorization header with a request in Swagger UI?

  3. 3

    'Authorization' header sent with request, but missing from apache_request_headers()

  4. 4

    How to remove header from AJAX call for a single request?

  5. 5

    How do I edit the authorization header of an HTTP GET request originating from a hyperlink (<a href> tag)

  6. 6

    .Net Windows webBrowser - how to extract authorization header from webBrowser response and send to another consecutive request?

  7. 7

    How to get value from header authorization bearer?

  8. 8

    How to fetch Authorization from page header?

  9. 9

    What is the proper way to grab Authorization header from controller request object?

  10. 10

    Swift 2 How do you add authorization header to POST request

  11. 11

    Swift 2 How do you add authorization header to POST request

  12. 12

    How to pass params and add authorization header in GET Request in Volley

  13. 13

    How to get code from Facebook Authorization request?

  14. 14

    Authorization header in Http Request in linkedin

  15. 15

    Request header field Authorization is not allowed

  16. 16

    How to remove (not modify) a request header in a Firefox addon?

  17. 17

    How to compute Basic Authorization header from username and password

  18. 18

    Authorization header missing in PHP POST request

  19. 19

    Guzzle HTTP - add Authorization header directly into request

  20. 20

    Authorization header not being sent in AJAX request

  21. 21

    angular $http GET request with authorization token header

  22. 22

    Sending Authorization Header with JWT in HTTP-Request

  23. 23

    Python requests: POST request dropping Authorization header

  24. 24

    Python POST request dropping Authorization header

  25. 25

    Python requests: POST request dropping Authorization header

  26. 26

    Why Authorization header is not send in API request in Angular?

  27. 27

    AFNetworking 2: Authorization header not included in request

  28. 28

    API Request with HTTP Authorization Header inside of componentDidMount

  29. 29

    Swagger Editor Not Passing Authorization in the Request Header

HotTag

Archive