# Identifying Pre-flight requests in Adapter

**URL:** <https://discuss.emberjs.com/t/identifying-pre-flight-requests-in-adapter/12507>\
**Category:** Ember Data\
**Created:** [February 27, 2017, 6:12pm UTC](https://discuss.emberjs.com/t/identifying-pre-flight-requests-in-adapter/12507 "2017-02-27T18:12:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Glancy](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Ben\_Glancy](https://discuss.emberjs.com/u/Ben_Glancy)\
**Post date:** [February 27, 2017, 6:12pm UTC](https://discuss.emberjs.com/t/identifying-pre-flight-requests-in-adapter/12507/1 "2017-02-27T18:12:07Z")

</div>

Hi,

I need to modify the host in the adapter so I came up with the following:

export default DS.JSONAPIAdapter.extend({ namespace: ‘arp/v2’,

```
host: function() {
	console.log("Environment is " + ENV.environment);
	
	// We don't want to hardcode the url here.
    if (ENV.environment === 'production' || ENV.environment === 'staging' ) {
        return 'https://www.room.com/arp/wp-json';
    } else {
        return 'http://localhost/arp/index.php/wp-json';
    }
}.property().volatile(), // volatile recalculates on every request

headers: {
	'X-WP-Nonce': 'b67698a8f9',
	'Content-type': 'text/plain'	
 },

```

});

My problem is that because it uses this for EVERY response it sends the X-WP-Nonce header on pre-flight requests, which causes the server to barf out CORS errors.

If there a way I can test for pre-flight requests and only add the header if it’s NOT pre-flight?

---

<div class="post-metadata">

**Author:** ![Ben\_Glancy](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Ben\_Glancy](https://discuss.emberjs.com/u/Ben_Glancy)\
**Post date:** [February 27, 2017, 6:34pm UTC](https://discuss.emberjs.com/t/identifying-pre-flight-requests-in-adapter/12507/2 "2017-02-27T18:34:00Z")

</div>

Ok answered my own question, the wp-json has a lot of filters etc you can control what is allowed and not allowed in the way of pre-flight headers
