Title: ionic   jwt auth : XMLHttpRequest cannot load
Last modified: August 30, 2016

---

# ionic jwt auth : XMLHttpRequest cannot load

 *  [reivax35](https://wordpress.org/support/users/reivax35/)
 * (@reivax35)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/ionic-jwt-auth-xmlhttprequest-cannot-load/)
 * Hello
 * I would like use wp rest api and jwt auth for create a mobile app.
    When i try
   to get token i have this error : XMLHttpRequest cannot load [http://localhost/wp_rest/wp-json/jwt-auth/v1/token/](http://localhost/wp_rest/wp-json/jwt-auth/v1/token/).
   Request header field Content-Type is not allowed by Access-Control-Allow-Headers
   in preflight response.
 * Any idea ?
    Thanks
 * [https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)

Viewing 1 replies (of 1 total)

 *  [webmaestro](https://wordpress.org/support/users/webmaestro/)
 * (@webmaestro)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/ionic-jwt-auth-xmlhttprequest-cannot-load/#post-6890395)
 * Looks like you need to update your Apache `.htaccess` file or your Apache `httpd.
   conf` file (assuming you’re running Apache). It’s different if you’re running`
   nginx`, `lighttpd` or some other web serverd… 😉
 *     ```
       <ifModule mod_headers.c>
               Header always set Access-Control-Allow-Origin: "*"
               Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
               Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
       </ifModule>
       ```
   
 * The first line `Header always set Access-Control-Allow-Origin: "*"` indicates
   that requests should be accepted from *any* domain.
 * Judging by the error, which explicitly indicates missing `Content-Type` that 
   may be all you need.
 * That said, you might need even more stuff (below you’ll find a more complete 
   listing, although this is un-tested and may need tweaking):
 *     ```
       <ifModule mod_headers.c>
               Header always set Access-Control-Allow-Origin: "*"
               Header always set Access-Control-Max-Age "1000"
               Header always add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
               Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"
       </ifModule>
       ```
   
 * By all means, if someone has better information, please add a comment!
 * This page has more info:
 * [https://awesometoast.com/cors/](https://awesometoast.com/cors/)
 * And you can also look here:
 * [https://www.google.com/search?q=wp%20rest%20api%20XMLHttpRequest%20preflight&rct=j](https://www.google.com/search?q=wp%20rest%20api%20XMLHttpRequest%20preflight&rct=j)

Viewing 1 replies (of 1 total)

The topic ‘ionic jwt auth : XMLHttpRequest cannot load’ is closed to new replies.

 * ![](https://ps.w.org/jwt-authentication-for-wp-rest-api/assets/icon-256x256.jpg?
   rev=3372068)
 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [webmaestro](https://wordpress.org/support/users/webmaestro/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/ionic-jwt-auth-xmlhttprequest-cannot-load/#post-6890395)
 * Status: not resolved