Proxy settings not working

After updating to ionic version 2.1.12 proxy settings are not working anymore. When calling paths defined in ionic.config.json, they end up pointing to the url at which the ionic server is running (i.e itself), and thus respond with 404 Not Found.

Yep, there was a bug in app-script. I think the fix is now merged so I guess it gonna be release with next version of app-script aka 0.0.46

Hi!!!
HEEELLLPP MEEE!! I’ve update my ionic2 and the proxy has stoped as well!

Can somebody help me? I need to deploy a new version next Saturday rs!

Thanks!!!

The last version of app-script (0.0.46) resolve the problem of proxy aka the proxies listed in ionic.config.json are supported again

I’ve just updated my ionic and it still does not work, where can I see this “app-script (0.0.46)”?

Thank you a lot!

In your package.json you should find

"devDependencies": {
    "@ionic/app-scripts": "0.0.46",

The proxies should be configured in ionic.config.json like

"proxies": [{
"path": "/mycontext/mysubcontext/etc",
"proxyUrl": "https://myserver.com/mycontext/mysubcontext/etc"
  },{
 ....

I did exactly the same but it keep point to http://localhost:8100/mycontext/mysubcontext. Do you know what else I need?

thanks,

In your classes you are calling http://localhost:8100/… right ?

yeah, in the class, I only call relative path. so the call url should be like this ‘/mycontext/mysubcontext’ and convert to http://localhost:8100/mycontext/mysubcontext in network tab but it doesnt show https://myserver.com/mycontext/mysubcontext/etc

Could you post here a sample of code and details? Also how does your ionic.config.json look like and which app-scrip version are you using ?

It’s solved the problem!! Thank you a lot!!

1 Like

I am having the same problem. I tried what’s suggested here (adding app-scripts 0.0.46) and still no luck.

Here’s my ionic.config.json:

{
“name”: “test”,
“app_id”: “”,
“proxies”: [
{
“path”: “/api_path/”,
“proxyUrl”: “http://localhost/test/api”
}
],
“defaultBrowser”: “chromium-browser”
}

Here’s my package.json:

{

“name”: “test”,
“version”: “1.1.1”,
“description”: “test: An Ionic project”,
“dependencies”: {
“gulp”: “^3.5.6”,
“gulp-sass”: “^2.0.4”,
“gulp-concat”: “^2.2.0”,
“gulp-minify-css”: “^0.3.0”,
“gulp-rename”: “^1.2.0”
},
“devDependencies”: {
“bower”: “^1.3.3”,
“gulp-util”: “^2.2.14”,
“shelljs”: “^0.3.0”,
"@ionic/app-scripts": “0.0.46”
},
“cordovaPlugins”: [
“cordova-plugin-device”,
“cordova-plugin-console”,
“cordova-plugin-whitelist”,
“cordova-plugin-splashscreen”,
“cordova-plugin-statusbar”,
“ionic-plugin-keyboard”
],
“cordovaPlatforms”: []
}

I did “npm install” and I am doing an “ionic serve”. My AJAX calls are still showing: http://localhost:8100/ so it is not doing the URL proxy. The proxy URL was working fine in an earlier project I did last year. What am I missing?

Here’s my ionic info:

Your system information:

Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.4.0

Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.3.2
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
Ionic App Scripts Version: 0.0.46
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v6.9.1

Thanks.

http://localhost:8100/ is the proxy url so I guess it’s ok that you see that address for your ajax queries…I guess

maybe try to change your proxy config. in my case path value is always the same as the proxy context and path value, like

{
  "path": "/test/api",
  "proxyUrl": "https://myserver.com/test/api"
}

Hmm I thought the problem was with the proxyUrl not working since I was seeing http://localhost:8100 in my AJAX queries but it turned out I had another problem with my path. It seems to be working now. Thanks for your response reedrichards.

1 Like

hey, @reedrichards it is not working in real device , working in emulator and browser but it’s not working in real device.

yep, that’s totally correct, this proxy settings above works only for Ionic >= 2 <= 3 and while debugging ionic serve

thanks @reedrichards , but i am using ionic 3, but it’s not working.
Is there any way to solve this problem.??

probably but unfortunately I don’t have a magical out of the box solution
good luck

https://forum.ionicframework.com/t/proxy-settings-not-working/70673/15?u=anujsinghwd
Is there any solution of my above problem @mhartington ?

no… it doesnt work… the app script is the stable 3.9 version… I can get other domain server files but I just query the one I need… And I dont know how to handle the server from sharepoint and asp… anyone can do a demo??