-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meteor loads incorrect HTTP handler, ignores object form of the "browser" field in package.json #15
Comments
Hey, @myktra - the error you are seeing is related to Meteor's incomplete support of the package.json "browser" field: meteor/meteor#6890 (comment) 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? |
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.
curl https://install.meteor.com/ | sh
From command line, create a new Meteor project.
meteor create myapp cd myapp
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:The text was updated successfully, but these errors were encountered: