HTML Imports and CORS from a local file, not from web server

3,937 views
Skip to first unread message

danel...@hotmail.com

unread,
Oct 28, 2014, 8:11:29 PM10/28/14
to polym...@googlegroups.com
On the Polymer site under Creating elements there is a note that says  
You must run your app from a web server for the HTML Imports polyfill to work properly. This requirement goes away when the API is available natively.
 
So lets say for an offline op where I am just opening an html file via open file or double clicking on it.  The html file is just a simple custom element that imports polymer.html

When I run this I get a CORS error
Imported resource from origin 'file://' has been blocked from loading by Cross-Origin Resource Sharing policy: Received an invalid response. Origin 'null' is therefore not allowed access. el.html:1
Uncaught ReferenceError: Polymer is not defined 

Is this the correct behavior since it is natively supported now in latest chrome according to above statement it should work, or is cors another issue.  I understand CORS and how to handle it when using a web server but not when just opening an html file via file://

Thanks,
Dan 

Eric Bidelman

unread,
Oct 29, 2014, 9:24:32 PM10/29/14
to danel...@hotmail.com, polymer-dev
I believe that's a leftover from an earlier time when we thought this would be the case.

HTML Imports follow the same restrictions as XHR:

- need to be fetched from http(s). Blink imposes security restrictions on what you can do with file://.
- CORs enabled if remote

We'll update that language.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/e9d635f5-11e7-4a9b-815c-aca93cd3df4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tkan...@gmail.com

unread,
May 10, 2015, 10:47:11 AM5/10/15
to polym...@googlegroups.com, danel...@hotmail.com
Dear Eric,

What is the current status of this case at May.,2015 ?

Taewon.

Eric Bidelman

unread,
May 10, 2015, 5:05:35 PM5/10/15
to tkan...@gmail.com, polym...@googlegroups.com, danel...@hotmail.com
I've fixed this in the FAQ: https://github.com/Polymer/docs/commit/bbf021f13701fd68b110509d4ab3c62c905e5f58

The restrictions I mentioned last Oct. still hold.

Taewon

unread,
May 10, 2015, 11:59:20 PM5/10/15
to Eric Bidelman, polym...@googlegroups.com, danel...@hotmail.com
For using Polymer at node-webkit environment, we can use app protocol of nw.js  for this issue. 
Reference site is https://github.com/nwjs/nw.js/wiki/App-protocol.

Thanks,
Taewon
--
Thanks & Regards,
Taewon Kang
Reply all
Reply to author
Forward
0 new messages