Using Ionic / NodeJS behind a proxy


#1

Hello,

I’m new to Ionic / NodeJS and have been trying to start a sample project following the instructions on the Getting Started page, but I’ve ran into a problem when trying to pass through the company’s proxy when executing the “ionic start myApp tabs” command.

I’ve been able to configure NodeJS by setting the “http” and “https-proxy” properties, but this configuration seems to be completely ignored by the “ionic” command :

C:\ionic>ionic start myApp tabs Running start task... Creating Ionic app in folder C:\ionic\myApp based on tabs project DOWNLOADING: https://github.com/driftyco/ionic-app-base/archive/master.zip TypeError: Cannot read property 'statusCode' of undefined at Request._callback (C:\Users\yba\AppData\Roaming\npm\node_modules\ionic\lib\ionic.js:241:13) at self.callback (C:\Users\yba\AppData\Roaming\npm\node_modules\ionic\node_modules\request\request.js:129:22) at Request.EventEmitter.emit (events.js:95:17) at ClientRequest.self.clientErrorHandler (C:\Users\yba\AppData\Roaming\npm\node_modules\ionic\node_modules\request\request.js:239:10) at ClientRequest.EventEmitter.emit (events.js:95:17) at CleartextStream.socketErrorListener (http.js:1547:9) at CleartextStream.EventEmitter.emit (events.js:95:17) at Socket.onerror (tls.js:1445:17) at Socket.EventEmitter.emit (events.js:117:20) at net.js:441:14

The problem I face (and the workaround I’m using) is described there.

Is it normal ? If not should I file an issue for this ?

Thank you for your help,

Yannick


【Error】Add ios platform error
#2

I have the same problem!!!


#3

I don’t know if anyone solved it. Can you try some of the options listed here:


#4

I have the same problem too!


#5

Hey guys,

Are you all on Windows, or other OSes?

As a temporary solution, you could use a tool like Proxifier (http://www.proxifier.com/) to automatically do this for the ionic start command. I need to look into seeing how to make this configurable on our end, I would just expect it to work automatically through global node settings but I guess not.


#6

@max Perhaps use an .ionicrc file in the project root to define some custom Ionic related settings? Just like Bower and JSHint.


#7

http://www.jasonwatmore.com/post/2014/04/02/Ionic-Framework-Getting-ionic-start-appName-Working-Behind-a-Proxy.aspx

Work for me.


#8

@max I’m Mac OS X 10.9.2


#9

There’s been an update the CLI that should take care of this.

$ sudo npm uninstall -g ionic
$ sudo npm install -g ionic
$ PROXY=http://myproxy.com:8081 ionic start what

#10

I am using latest version of ionic, but still I face the above error. Using your answer I have fixed it.

Thanks,
Praveen


#11

I still have this problem, I’m going to try and follow the blog mentioned

Is there a Windows equivalent of PROXY= please?

Thank you

(love Ionic btw, it’s transformed me and my partners development, if you’re ever in Somerset, England we owe you beers).


#12

Oh, I resolved it - you need to set an Environment Variable in windows for PROXY :slight_smile:

Thank you


#13

I have proxy setup for npm install. I can create ionic app but can’t upload it. any solution ?


#14

Works

C:_Source2324\12345>set proxy=http://1x.y.z.k:8080

C:_Source2324\12345>ionic start mySMSApp tabs
Creating Ionic app in folder C:_Source\SMSApp\mySMSApp based on tabs project
Downloading: https://github.com/driftyco/ionic-app-base/archive/master.zip
[=============================] 100% 0.0s
Downloading: https://github.com/driftyco/ionic-starter-tabs/archive/master.zip
[=============================] 100% 0.0s
Updated the hooks directory to have execute permissions
Update Config.xml
Initializing cordova project

Your Ionic project is ready to go! Some quick tips:

  • cd into your project: $ cd mySMSApp

  • Setup this project to use Sass: ionic setup sass

  • Develop in the browser with live reload: ionic serve

  • Add a platform (ios or Android): ionic platform add ios [android]
    Note: iOS development requires OS X currently
    See the Android Platform Guide for full Android installation instructions:
    https://cordova.apache.org/docs/en/edge/guide_platforms_android_index.md.html

  • Build your app: ionic build

  • Simulate your app: ionic emulate

  • Run your app on a device: ionic run

  • Package an app using Ionic package service: ionic package

For more help use ionic --help or ionic docs

Visit the Ionic docs: http://ionicframework.com/docs

Create an ionic.io account to send Push Notifications and use the Ionic View app
?
(Y/n): n
±--------------------------------------------------------+

±--------------------------------------------------------+

C:_Source2324\12345>


#15

Thanks! The solution provided by @mhartington solved this issue I was having with the f… building’s proxy
https://forum.ionicframework.com/t/cannot-read-property-statuscode-of-undefined-cli-js-474/56301


#16

For windows you can also set an Environment variable called PROXY.
It worked for me.


#17

hey how to set in windows please give me some example .
Thank You.


#18

in your config file you have to mention proxies property as below

“proxies”: [
{
“path”: “/api”,
“proxyUrl”: “https://www.abc.com/api
}


#19

Worked for me.Thanks.

On commandline: set PROXY=http://your_company_proxy:8080


#20

set PROXY=http://(…)