# Cannot redirect to Discourse. Error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

**URL:** <https://meta.discourse.org/t/cannot-redirect-to-discourse-error-response-to-preflight-request-doesnt-pass-access-control-check-no-access-control-allow-origin-header-is-present-on-the-requested-resource/65191>\
**Category:** WordPress\
**Created:** [27.Июнь.2017 12:06:09 UTC](https://meta.discourse.org/t/cannot-redirect-to-discourse-error-response-to-preflight-request-doesnt-pass-access-control-check-no-access-control-allow-origin-header-is-present-on-the-requested-resource/65191 "2017-06-27T12:06:09Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [29.Июнь.2017 03:13:17 UTC](https://meta.discourse.org/t/cannot-redirect-to-discourse-error-response-to-preflight-request-doesnt-pass-access-control-check-no-access-control-allow-origin-header-is-present-on-the-requested-resource/65191/6 "2017-06-29T03:13:17Z")

</div>

If it was my site, I’d just do something like this, to add a login button to the WordPress menu that will automatically login and create users.

```php
add_filter( 'wp_nav_menu_items', 'discourse_community_link', 10, 2 );
function discourse_community_link( $items, $args ) {
	if ( 'primary' === $args->theme_location ) {
		if ( is_user_logged_in() ) {
			$community_link = '<li><a href="http://localhost:3000/session/sso?return_path=/">Community</a> </li>';
		} else {
			$community_link = '<li><a href="http://localhost:3000">Community</a> </li>';
		}
		$items = $items . $community_link;
	}

	return $items;
}

```

It can also be done by embedding a Discourse `iframe` on the page that users are redirected to after logging in. Look at part C of this guide for how to do it: [https://meta.discourse.org/t/wordpress-integration-guide/27531?u=simon\_cossar](https://meta.discourse.org/t/wordpress-integration-guide/27531) I think you need to use an `embed` tag instead of an `iframe` to get it to work.

Edit: the code I added above is assuming your menu location is called ‘primary’. It could be called something else. You can check the value of the `$args` parameter to see what it is.

---

_[View the full topic](https://meta.discourse.org/t/cannot-redirect-to-discourse-error-response-to-preflight-request-doesnt-pass-access-control-check-no-access-control-allow-origin-header-is-present-on-the-requested-resource/65191)._
