Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

port number swallowed by Route(template, defaults), yielding 12029 from IE9 #942

Closed
yeswaydude opened this issue May 8, 2012 · 7 comments

Comments

@yeswaydude
Copy link

I finally tracked down why my AJAX service wasn't working. The debuggers in IE9 and Firefox kept saying that my request had been aborted. At least IE9 showed an xhr.status of 12029, giving a nebulous indication that something was wrong with the network.

While debugging through the code, I noticed that my HTTP port number (which follows the server, separated by a colon) was getting removed from my URL (http://localhost:88/...).

I tracked it to function Route(template, defaults) and its search for URL parameters via regular expression. Apparently, 88 also gets encoded to an empty string (or some non-printable character?).

In case anyone else runs into this and needs a workaround, I was simply able to drop the prefix from my URL and allow the relative URL mechanism to take over. For example, http://localhost:88/a/b/c --> /a/b/c.

@IgorMinar
Copy link
Contributor

There are several things going on here:

  • it doesn't make sense to use absolute urls in $resource definition if you are talking to the same server that served up the application. Always use relative urls in this case
  • if you do need to specify absolute url because you are doing JSONP or CORS then you need to escape the port number with \ because colon : is used by the $resource service to denote url variables. So in this case use: http://someserver.com\:8080/path

@JamesDunne
Copy link

Please switch to curly-wrapped url variables because they're clearer, curlies are rarely used in urls, a start/end pair of curlies can unambiguously denote a name including special chars, and because colon-prefixed is just strange in a URL that may contain colons for port numbers.
Also, when writing a non-hosted chrome web app, absolute URLs are your only choice for grabbing data from servers.

@AutomatedBusinessLogic
Copy link

Wow! This problem has wasted several hours of my time. Yes, when using resources, you must escape the colon for the port number in your URL. You may have to double-escape it, e.g. "http://foo.com\\:8080/blah".

Thanks for the tip!

@nbardy
Copy link

nbardy commented Oct 26, 2012

Just had this same problem had to double escape like above user e.g. "http://localhost\\:9292/phones"

@JamesDunne
Copy link

Strings literals always have to have backslash escaping rules applied. angular.js does not make any special exception here.

To put a literal backslash character into a string, one must always escape it with a backslash, e.g. "\".

@cmdrkeene
Copy link

There is a also a disparity between how $resource and $http handle this.

For example, if you use a common config variable with the double port (http://localhost:3000\:3000) as proposed above:

  • $http requests go to http://localhost:3000:3000
  • $resource requests go to http://localhost:3000

@azzamallow
Copy link

Im using angular 1.0.4 and are getting a similar issue (swallowed port).

@IgorMinar, in response to having absolute urls, it makes sense in my situation. Im deploying an angular application to phonegap. I need to specify the full url for the resources to work properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants