-
Notifications
You must be signed in to change notification settings - Fork 726
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
Allow Relative Path Urls #28
Comments
While allowing relative paths in the browser certainly makes sense, it would be broken by the cluster discovery functionality. Maybe you should try this approach instead: angular.module('components.search')
.service('es', function (esFactory) {
return esFactory({
host: window.location.protocol + '//' + window.location.host + '/services/elastic'
});
}); |
Well, that doesn't allow us to use grunt-connect-proxy (https://github.com/drewzboto/grunt-connect-proxy). Grunt connect proxy is specifically looking for relative path requests made through $http which it then reroutes through grunt (node) server side to the actual web server configured in grunt. Your suggestion is causing http requests to http://localhost/services/elastic instead of http://localhost:9000/services/elastic. I'll try a couple other things and report what's happening while I debug through the code. |
As far as I know we're using this library to just query elastic search (http://elasticsearch.github.io/elasticsearch-js/api.html#search). Perhaps we can just use raw $http requests with the elastic dsl in the http request body. |
That's a fair observation. If you are only doing search queries, and your entire cluster is behind a load balancer, then using elasticsearch.js in the browser is probably overkill. |
Not sure why I didn't think about this earlier, but you do something like this: return esFactory({
host: {
host: '',
port: '',
path: '/services/elastic'
}
}); right now this will cause the requests to go to |
Nice, great thinking @spenceralger. |
@DeanPoulin Just updated the master build, if you want to give it a shot. Check out the unit tests for an example. |
@spenceralger thanks for your help, I'll give it a spin and let you know how it goes. Much appreciated. |
fixed undefined is not function issue for expires
We currently use grunt with grunt-connect-proxy for local development so that we can code our front end to use relative path AJAX requests to avoid cross site request issues.
When we deploy the application to other environments we simply configure the load balancer to perform the same type of proxying of relative path requests to other servers/ports server side.
I'm attempting to configure the esFactory as such:
and using elasticsearch.angular.js but the AJAX requests are being made to http://localhost/services/elastic instead of /services/elastic
This is causing collisions with the way grunt runs the application in development on a url like http://localhost:9000/#/
Can we update the code to not assume I want to prefix the AJAX requests with http://localhost if I specify a host with a a leading slash?
This might just be achievable through a new configuration param:
and specifically handled in elasticsearch.angular.js when making the call with $http
The text was updated successfully, but these errors were encountered: