Why do I need a server?

277 views
Skip to first unread message

nishantag...@gmail.com

unread,
Jul 12, 2014, 5:00:00 AM7/12/14
to polym...@googlegroups.com
HI, I'm following this tutorial on polymer-project.org. In it it says that I need a web server to test my pages.
I'm sorry if this is a very stupid question, but why do I need a web server? Why don't the pages work if you simply open the index.html files locally in the browser? I just want to understand. By my reasoning it should work the same way whether it is loaded from a remote server or the local filesystem.

piturc...@gmail.com

unread,
Jul 12, 2014, 5:30:30 AM7/12/14
to polym...@googlegroups.com, nishantag...@gmail.com
Its probably due to the fact the without a server the imports wouldn’t be allowed under the browser’s same origin policy.
You can bypass that by opening Chrome with --allow-file-access-from-files flag:

Just set up a shortcut with the following target: C:\Users\Admin\AppData\Local\Google\Chrome\Application\chrome --allow-file-access-from-files and it should work

nishantag...@gmail.com

unread,
Jul 12, 2014, 8:34:45 AM7/12/14
to polym...@googlegroups.com, nishantag...@gmail.com, piturc...@gmail.com
Thanks for your reply :)
I did as you said and ran chrome with the flag, but it did not have any effect. The page still appears blank when I open the file locally but works properly if I open it through the local server. Any idea why?

nishantag...@gmail.com

unread,
Jul 12, 2014, 9:54:57 AM7/12/14
to polym...@googlegroups.com, nishantag...@gmail.com, piturc...@gmail.com
Actually, I had a different window of chrome open when I tried that so it did not work as the flag wasn't enabled. I tried it again after closing all chrome windows and it worked. My bad. Thanks for your help :)

piturc...@gmail.com

unread,
Jul 12, 2014, 10:17:20 AM7/12/14
to polym...@googlegroups.com, nishantag...@gmail.com, piturc...@gmail.com
Yeah, everything needs to be closed before. Also the next time you open the browser, in the shortcut instead of C:\Users\Admin\AppData\Local\Google\Chrome\Application\chrome --allow-file-access-from-files you may see C:\Users\Admin\AppData\Local\Google\Chrome\Application\chrome.exe --allow-file-access-from-files. Remove the .exe again

Nishant George Agrwal

unread,
Jul 12, 2014, 10:20:41 AM7/12/14
to polym...@googlegroups.com
Thanks. Actually I'm on linux. Ubuntu to be precise. So for reference, on Ubuntu the command to run would be "google-chrome --allow-file-access-from-files".
Reply all
Reply to author
Forward
0 new messages