Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to Enable Auto-Discovery #508

Open
emiltsang opened this issue Aug 17, 2022 · 0 comments
Open

Failed to Enable Auto-Discovery #508

emiltsang opened this issue Aug 17, 2022 · 0 comments

Comments

@emiltsang
Copy link

emiltsang commented Aug 17, 2022

I was trying to enable the Auto-Discovery with
var apiPromise = WPAPI.discover( 'http://my-site.com' );.

I have added the send_header function to functions.php under the theme folder.

add_action( 'send_headers', function() {
	if ( ! did_action('rest_api_init') && $_SERVER['REQUEST_METHOD'] == 'HEAD' ) {
		header( 'Access-Control-Allow-Origin: *' );
		header( 'Access-Control-Expose-Headers: Link' );
		header( 'Access-Control-Allow-Methods: HEAD' );
	}
} );

However, I got the following errors

 ERROR  No header link found with rel="https://api.w.org/"                                                                                                                 
  at locateAPIRootHeader (node_modules/wpapi/lib/autodiscovery.js:32:8)
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (internal/process/task_queues.js:95:5)


 ERROR  Autodiscovery failed                                                                                                                                              
  at node_modules/wpapi/wpapi.js:465:10
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (internal/process/task_queues.js:95:5)

Can I check that the send_header function is placed in the correct file?
Also, where should I place the plugin.php file for rest-filter plugin?
rest-filter plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant