{"id":3383,"date":"2016-03-13T23:54:59","date_gmt":"2016-03-13T23:54:59","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3383"},"modified":"2016-03-13T23:54:59","modified_gmt":"2016-03-13T23:54:59","slug":"expressjs-proxy-requests-solr-2","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/expressjs-proxy-requests-solr-2\/","title":{"rendered":"Expressjs: proxy requests to Solr"},"content":{"rendered":"<p>To proxy requests to solr in ExpressJS, you can use the HTTP proxy:<\/p>\n<pre lang=\"bash\">\nnpm install express-http-proxy --save\n<\/pre>\n<p>When you set this up, you can add the core (here called new_core), and any arguments you want added by default:<\/p>\n<pre lang=\"javascript\">\nvar proxy = require('express-http-proxy');\n\napp.use('\/execute', \n  proxy('http:\/\/localhost:8983', {\n    forwardPath: function(req, res) {\n      return '\/solr\/new_core\/select?wt=json&indent=true&' + \n        require('url')\n          .parse(req.url)\n          .path\n          .substring('execute\/'.length);\n    }\n  }\n));\n<\/pre>\n<p>This will pass anything that goes to &#8220;\/execute&#8221; to your Solr core.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To proxy requests to solr in ExpressJS, you can use the HTTP proxy: npm install express-http-proxy &#8211;save When you set this up, you can add the core (here called new_core), and any arguments you want added by default: var proxy = require(&#8216;express-http-proxy&#8217;); app.use(&#8216;\/execute&#8217;, proxy(&#8216;http:\/\/localhost:8983&#8217;, { forwardPath: function(req, res) { return &#8216;\/solr\/new_core\/select?wt=json&#038;indent=true&#038;&#8217; + require(&#8216;url&#8217;) .parse(req.url) .path &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/expressjs-proxy-requests-solr-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Expressjs: proxy requests to Solr&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[210,302,389,517],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3383"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3383"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3383\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}