How to make polymer serve be accessible on the internet or Lan, instead localhost? - polymer

I have a Polymer 2 component that I serve locally running
polymer serve
I get the following back:
Files in this directory are available under the following URLs
applications: http://127.0.0.1:8081
reusable components: http://127.0.0.1:8081/components/component-name/
That works very well; as expected I am able to open a local URL and view the component on Chrome.
I need to test this component on an Android Device, the best way it would be (please correct me if I´m wrong) to make this polymer component available on the internet or my local network.
Any suggestion is appreciated. thanks.

When you use the serve command you have some additional parameters. With one of them (-H) you can set the IP you want to be used. So instead of launching the server for your loopback (localhost) IP (the default), you can use your LAN IP (I guess most likely something like 192.169.x.x), or even:
polymer serve -H 0.0.0.0
"0.0.0.0" basically meaning "all IPv4 addresses on the local machine". So now you only need to know your IP in the network you are and that Android device is connected also. So if both of them are connected to the same router you should be able to open in your phone an URL like http://192.168.x.x:8081

Related

Disable internet access for testing ionic app but still serve files from localhost

I have an app that I'm testing on localhost via ng serve, and want to test the app offline.
I know in dev tools I can disable network access, however, this also prevents the files being served from localhost.
Currently, the only way I have found to test the app offline whilst still serving the files from localhost is simply to enable flight mode on my own computer, however, is there another way to achieve this?
Example screenshot, running ng serve whilst network is disabled
I think you are on the right path, but definitely there are alternatives to achieve the same results. The other possible ways I can think of:
Changing Internet Proxy Settings to point to a non-existent server, will block all your outgoing traffic but localhost.
Block outgoing traffic with Firewall.

Local debugging of subdomains with VS 2015

I have a multi-tenant website that has to take care of any incoming request and determine the appropriate routing by the URL subdomain.
I set up the subdomain routing using this or a similar solution.
However I'm trying to access my website on my local machine using subdomains an alias website. I'm unable to get my local IIS to port to my website with the subdomain I've specified.
I want to dedicate a virtual domain name in my local machine that will port to the website I'm debugging on VS (localhost:23456).
I've read some answers of identical questions (like this or this one), but it looks like the system has changed with the new IIS and Visual Studio 2015 and ASP.NET 5 MVC 6 (vNext) project configuration.
Here's what I've tried according to the answers linked above:
I tried setting the hosts file porting www.myexample.com to 127.0.0.1 but I get a "Bad request" error when navigating to www.myexample.com:23456 in my browser, and anyway the debugger doesn't report a request.
I tried setting <binding protocol="http" bindingInformation=":23456:www.myexample.com" /> in the applicationhost.config file, gets IIS to raise an error saying "Replace hostname with localhost. Any other bindingInformation not specificying localhost as the website raises that IIS error.
Update
After opiants answer
I knew about the .vs folder and that's were I was configuring the bindings indeed.
However, looks like it was the permission that caused IIS to throw errors.
Running that netsh command solved the issue. And BTW, since I'm only running it my own machine, I'm not gonna need to open the firewall.
Anyway my question is if there is a way to add a wildcard instead of each subdomain separately? Since each tenant gets a unique subdomain, the whole process of adding subdomains is going to be dynamic by nature. I need to allow an asterisk in all the 3 places:
hosts file
applicationhost.config file
netsh command
It looks like I can add the asterisk in those places but it doesn't actually work.
I'm guessing you're using IIS express locally?
If so, in your solution directory, there is a .vs folder. You need to add the binding in the \config\applicationhost.config file inside that folder. Then make sure that you've allowed IIS express to listen to that subdomain.
You can refer to Scott's article on how to configure IIS Express. Specifically look for this paragraph "1. GETTING IIS EXPRESS TO SERVE EXTERNALLY OVER PORT 80"
To be more specific, you need to run these commands:
netsh http add urlacl url=http://{your-domain}:{custom-port}/ user=everyone
netsh firewall add portopening TCP {custom-port} IISExpressWeb enable ALL

jekyll serve is not serving in localhost and showing other page

I have install jekyll and have used it in my blog creation.
But when i type the command
jekyll serve
It show an address 0.0.0.0:4000
Which is not local host.
Also,The address shows a blank page instead of my blog.
Help me to solve this Problem.
jekyll serve always shows :
Server address: http://0.0.0.0:4000
It doesn't mean that the website will be displayed on this IP address : it isn't an IP address! It means "server, listen on every available network interface". 127.0.0.1 is a network interface, so the server should listen to it.
That is to say localhost:4000 (or 127.0.0.1) should display your website. If not, the problem isn't related to this strange 0.0.0.0:4000.
With using 0.0.0.0 you able to access it from another device using your machine IP address in the same network.

Access HTML page on local network

Say I have this HTML page , I want when some one on my local network type my(ip) or my computer Name in a browser to view that HTML page
You just have to edit the httpd configuration file and ensure that the default port is set to 80, as by default it should use that anyhow, 8080 is the alternate one.
If you use a local network then the rest of the users in it should be able to reach the website on http://your-computer-name, otherwise if for any other reasons that's not configured then they'll have to use the IP address.
They can also edit their local hosts file (in Windows for eg.) and have something like:
your.IP any-name
any-name being either your computer name or website name, as it will be a direct maping

unsupported address error when trying to access page on specific port in a LAN

when I try to access a page on my IIS Express in a LAN (e.g. 192.168.1.123:3766/Host/MyPage.aspx) from my HTC 8S with Windows Phone 8 I get an error message that says "Unsupported address Internet Explorer Mobile doesn't support this type of address and can't display this page.
Is it possible to get this to work and if so how?
You need to specify the protocol. Try http://192.168.1.123:3766/Host/MyPage.aspx.
You will also need to follow the instructions here to make sure that your IIS Express is serving up on a port which your phone can see.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx
In particular follow this section:
Quick solution with IIS Express
Create a firewall exception to allow HTTP requests through the firewall on the port that IIS Express is using.
Get the IP address of the development computer, if necessary, by running ipconfig.
Find the IIS Express configuration file, applicationhost.config, in the folder %USERPROFILE%\Documents\IISExpress\config. The USERPROFILE environment variable typically has a value of C:\Users\.
Open applicationhost.config with Notepad or another text editor and make the following changes.
a. Find the site element for the web service, WebServiceForTesting.
b. If you don’t see the site element for the web service, you have to deploy the service at least one time to create the element.
c. Within the bindings section of the site element, copy the binding element and paste a copy directly below the existing binding element to create a second binding.
d. In the new binding element, replace localhost with the computer’s IP address.
Save the changes.
Run Visual Studio as administrator and open the Visual Studio solution.
And beware of:
Important Note:
On a corporate domain, the emulator appears as a separate network device that is not joined to the domain. As a result, you may also have to get an exception from your IT department before the emulator can connect to services that are running on the domain-joined development computer.