{"id":955,"date":"2016-07-27T09:08:45","date_gmt":"2016-07-27T07:08:45","guid":{"rendered":"http:\/\/blog.thecodecampus.de\/?p=955"},"modified":"2023-12-20T20:09:50","modified_gmt":"2023-12-20T19:09:50","slug":"ionic-2-proxy-development","status":"publish","type":"post","link":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/","title":{"rendered":"Ionic 2 Proxy while Development with Gulp"},"content":{"rendered":"<p>From time to time you may need to add a proxy to your Ionic 2 project. It is actually really simple but many articles in the web still refer to the old Ionic 2 build using webpack. Since it is now gulp based\u00a0and modularized you must use the <strong>ionic.config.json<\/strong> file in order to create a new <strong>proxy<\/strong> listening on your apps port (pbl. 8100).<\/p>\n<pre class=\"lang:default decode:true \" title=\"ionic.config.json\">{\r\n  \"name\": \"client\",\r\n  \"app_id\": \"\",\r\n  \"v2\": true,\r\n  \"typescript\": true,\r\n  \"proxies\": [\r\n    {\r\n      \"path\": \"\/api\",\r\n      \"proxyUrl\": \"http:\/\/someRemoteApi.com\/api\/v2\"\r\n    }\r\n  ]\r\n}\r\n<\/pre>\n<p><strong>Thats it!<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>If you still experience troubles: Try to verify that your proxy works. This can be achieved by installing the handy npm module \u00a0http-server. Then set up a server on a different port, call the proxy URL in chrome and see if the request is shown in the logs:<\/p>\n<pre class=\"lang:sh decode:true \" title=\"test a proxy \"># install http server\r\nnpm i -g http-server\r\n\r\n# run http server\r\nhttp-server -p 9988\r\n\r\n# in another terminal, make sure ionic runs\r\nionic serve\r\n\r\n# then go to chrome\r\n# and call the ionic localhost URL + the proxies.path from ionic.config.json\r\n# -&gt; e.g.localhost:8100\/api\r\n\r\n# Now take a look at your http-server console:\r\n\r\n# can@xmg:~ $ http-server -p 9988\r\n# Starting up http-server, serving .\/\r\n# Available on:\r\n#   http:\/\/127.0.0.1:9988\r\n#   http:\/\/192.168.1.150:9988\r\n#   http:\/\/192.168.1.199:9988\r\n# Hit CTRL-C to stop the server\r\n# [Wed Jul 27 2016 09:06:43 GMT+0200 (CEST)] \"GET \/api\/v2\/\" \"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Ubuntu Chromium\/51.0.2704.79 Chrome\/51.0.2704.79 Safari\/537.36\"\r\n# [Wed Jul 27 2016 09:06:43 GMT+0200 (CEST)] \"GET \/api\/v2\/\" Error (404): \"Not found\"\r\n\r\n\r\n<\/pre>\n<p>As we can see in the last two lines, the request has gotten trough &#8211; proxy definitely works!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From time to time you may need to add a proxy to your Ionic 2 project. It is actually really simple but many articles in the web still refer to the old Ionic 2 build using webpack. Since it is now gulp based\u00a0and modularized you must use the ionic.config.json file in order to create a [&#8230;]<br \/><a class=\"meta-big\" href=\"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/\"> READ MORE<\/a><\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-955","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ionic 2 Proxy while Development with Gulp - Web Development Blog<\/title>\n<meta name=\"description\" content=\"Elevate Ionic 2 development. Master proxy setup, optimize API interactions effortlessly. Boost efficiency\u2014revolutionize your Ionic experience!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ionic 2 Proxy while Development with Gulp - Web Development Blog\" \/>\n<meta property=\"og:description\" content=\"Elevate Ionic 2 development. Master proxy setup, optimize API interactions effortlessly. Boost efficiency\u2014revolutionize your Ionic experience!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development tips and tricks - theCodeCampus Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-27T07:08:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-20T19:09:50+00:00\" \/>\n<meta name=\"author\" content=\"theCodeCampus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"theCodeCampus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/\"},\"author\":{\"name\":\"theCodeCampus\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/276bbda2f8da73154f22fb652201cfbc\"},\"headline\":\"Ionic 2 Proxy while Development with Gulp\",\"datePublished\":\"2016-07-27T07:08:45+00:00\",\"dateModified\":\"2023-12-20T19:09:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/\"},\"wordCount\":141,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/\",\"name\":\"Ionic 2 Proxy while Development with Gulp - Web Development Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\"},\"datePublished\":\"2016-07-27T07:08:45+00:00\",\"dateModified\":\"2023-12-20T19:09:50+00:00\",\"description\":\"Elevate Ionic 2 development. Master proxy setup, optimize API interactions effortlessly. Boost efficiency\u2014revolutionize your Ionic experience!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/ionic-2-proxy-development\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ionic 2 Proxy while Development with Gulp\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"name\":\"Web Development tips and tricks - theCodeCampus Blog\",\"description\":\"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\",\"name\":\"theCodeCampus\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"width\":156,\"height\":156,\"caption\":\"theCodeCampus\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/276bbda2f8da73154f22fb652201cfbc\",\"name\":\"theCodeCampus\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"caption\":\"theCodeCampus\"},\"description\":\"Our knowledge is not simply gained through reading - it is trained, tested and constantly being expanded. Because first and foremost, we are all developers at W11K. The know-how that we acquire here as developers, consultants and information architects flows immediately into our training courses and articles for theCodeCampus.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/showcase\\\/thecodecampus\\\/\"],\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ionic 2 Proxy while Development with Gulp - Web Development Blog","description":"Elevate Ionic 2 development. Master proxy setup, optimize API interactions effortlessly. Boost efficiency\u2014revolutionize your Ionic experience!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/","og_locale":"en_US","og_type":"article","og_title":"Ionic 2 Proxy while Development with Gulp - Web Development Blog","og_description":"Elevate Ionic 2 development. Master proxy setup, optimize API interactions effortlessly. Boost efficiency\u2014revolutionize your Ionic experience!","og_url":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/","og_site_name":"Web Development tips and tricks - theCodeCampus Blog","article_published_time":"2016-07-27T07:08:45+00:00","article_modified_time":"2023-12-20T19:09:50+00:00","author":"theCodeCampus","twitter_card":"summary_large_image","twitter_misc":{"Written by":"theCodeCampus","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/#article","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/"},"author":{"name":"theCodeCampus","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/276bbda2f8da73154f22fb652201cfbc"},"headline":"Ionic 2 Proxy while Development with Gulp","datePublished":"2016-07-27T07:08:45+00:00","dateModified":"2023-12-20T19:09:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/"},"wordCount":141,"commentCount":5,"publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/","url":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/","name":"Ionic 2 Proxy while Development with Gulp - Web Development Blog","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#website"},"datePublished":"2016-07-27T07:08:45+00:00","dateModified":"2023-12-20T19:09:50+00:00","description":"Elevate Ionic 2 development. Master proxy setup, optimize API interactions effortlessly. Boost efficiency\u2014revolutionize your Ionic experience!","breadcrumb":{"@id":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.thecodecampus.de\/blog\/ionic-2-proxy-development\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.thecodecampus.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Ionic 2 Proxy while Development with Gulp"}]},{"@type":"WebSite","@id":"https:\/\/www.thecodecampus.de\/blog\/#website","url":"https:\/\/www.thecodecampus.de\/blog\/","name":"Web Development tips and tricks - theCodeCampus Blog","description":"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.","publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.thecodecampus.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.thecodecampus.de\/blog\/#organization","name":"theCodeCampus","url":"https:\/\/www.thecodecampus.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","width":156,"height":156,"caption":"theCodeCampus"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/276bbda2f8da73154f22fb652201cfbc","name":"theCodeCampus","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","caption":"theCodeCampus"},"description":"Our knowledge is not simply gained through reading - it is trained, tested and constantly being expanded. Because first and foremost, we are all developers at W11K. The know-how that we acquire here as developers, consultants and information architects flows immediately into our training courses and articles for theCodeCampus.","sameAs":["https:\/\/www.linkedin.com\/showcase\/thecodecampus\/"],"url":"https:\/\/www.thecodecampus.de\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/comments?post=955"}],"version-history":[{"count":4,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/955\/revisions"}],"predecessor-version":[{"id":1267,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/955\/revisions\/1267"}],"wp:attachment":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/media?parent=955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/categories?post=955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/tags?post=955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}