A user wants to configure SearchPress to connect to a server that requires authentication (such as aws.found.io). There is a condition in the code similar to this one:
If a user then attempts to update the ES instance URL, and checks the box to request an immediate full sync, the action that configures the authentication runs before the option is updated in the database, so when SearchPress attempts to connect to the ES instance, the authorization headers aren't set, and it returns an error message to the user indicating that the server could not be reached. However, if the user tries again once the option has been set, it succeeds.
Suggested Action
Add a filter to the request method of SP_API that allows the request defaults to be filtered before running the remote request, to allow users to reliably set authentication headers (and other types of default request headers) before the request is sent, and/or allow users to filter the entire set of request parameters before the request is sent.
Scenario
A user wants to configure SearchPress to connect to a server that requires authentication (such as aws.found.io). There is a condition in the code similar to this one:
This action runs on the
after_setup_theme
hook.If a user then attempts to update the ES instance URL, and checks the box to request an immediate full sync, the action that configures the authentication runs before the option is updated in the database, so when SearchPress attempts to connect to the ES instance, the authorization headers aren't set, and it returns an error message to the user indicating that the server could not be reached. However, if the user tries again once the option has been set, it succeeds.
Suggested Action
Add a filter to the
request
method ofSP_API
that allows the request defaults to be filtered before running the remote request, to allow users to reliably set authentication headers (and other types of default request headers) before the request is sent, and/or allow users to filter the entire set of request parameters before the request is sent.