Closed myktra closed 6 years ago
Hey, @myktra - the error you are seeing is related to Meteor's incomplete support of the package.json "browser" field: https://github.com/meteor/meteor/issues/6890#issuecomment-214032062
In this case, the server-side HTTP handler is being loaded, which isn't intended for client-side use. The solution you found works since it is loading the correct client-side functionality. I'm trying to think of a better work-around that we might support in the SDK, but it looks like the Meteor might pick this issue up soon.
Thanks for reporting, and I'm really sorry about the headache!
@dustinlarimer thank you for the analysis; does implementing something like this satisfy both Node.js and Meteor users? Or do you think that's a step in the wrong direction?
https://github.com/axic/keccakjs/pull/3/commits/c95501f9e55c1b7bad1e51ef2eaef5118ad15ab5
Hey @myktra, sorry for the late reply here. The type of workaround you're suggesting would certainly work, but unfortunately this will require a hefty rewrite of the core http-handling logic. I can't say for certain if or when we can fix this, but it's definitely on my radar.
OK, thank you for the update! Workaround seems manageable for now.
Keen's CORS restrictions don't seem to allow the use of this library from the browser when added in npm package form to a Meteor application.
If the script is served from the Keen CDN, as documented here – you'd need to use the
kadira:dochead
package to add the script dynamically – all works fine, but then you don't appear to need this package installed. There are some obvious benefits to using the npm version in terms of version control and dependency management.Is this by design, for security reasons, or am I perhaps missing something?
To reproduce this behavior, follow these steps:
Install Meteor.
From command line, create a new Meteor project.
Add the
keen-analysis
package and start your app.Note that Meteor packages the
keen-analysis
scripts and serves them to the browser. The Keen object is then available for any browser-based code to execute.Add the following code to
client/main.js
:Hit
http://localhost:3000
.Observe via Chrome's developer tools that the query request is rejected due to a CORS preflighting issue.
Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
Using
kadira:dochead
, using the CDN version works fine: