Skip to content
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

Problems using algoliasearch via npm on the client #292

Closed
nerdmed opened this issue Jun 30, 2016 · 3 comments
Closed

Problems using algoliasearch via npm on the client #292

nerdmed opened this issue Jun 30, 2016 · 3 comments
Labels

Comments

@nerdmed
Copy link

nerdmed commented Jun 30, 2016

Dear algolia devs ;) - I am getting the same issues that are fixed for in this issue for instantsearch.js on meteor when using the algolia client in a meteor enviroment.

I get the following error:

request.js:113 Refused to set unsafe header "connection"Request.end @ request.js:113doReq @ node.js:156request @ node.js:94doRequest @ AlgoliaSearchCore.js:250AlgoliaSearchCore._jsonRequest @ AlgoliaSearchCore.js:388IndexCore._search @ IndexCore.js:234search @ buildSearchMethod.js:44_queryAlgolia @ app.js?hash=7e0101f…:13943search @ app.js?hash=7e0101f…:13867(anonymous function) @ app.js?hash=7e0101f…:13698later @ underscore.js:731
request.js:113 Refused to set unsafe header "accept-encoding"Request.end @ request.js:113doReq @ node.js:156request @ node.js:94doRequest @ AlgoliaSearchCore.js:250AlgoliaSearchCore._jsonRequest @ AlgoliaSearchCore.js:388IndexCore._search @ IndexCore.js:234search @ buildSearchMethod.js:44_queryAlgolia @ app.js?hash=7e0101f…:13943search @ app.js?hash=7e0101f…:13867(anonymous function) @ app.js?hash=7e0101f…:13698later @ underscore.js:731
request.js:113 Refused to set unsafe header "content-length"Request.end @ request.js:113doReq @ node.js:156request @ node.js:94doRequest @ AlgoliaSearchCore.js:250AlgoliaSearchCore._jsonRequest @ AlgoliaSearchCore.js:388IndexCore._search @ IndexCore.js:234search @ buildSearchMethod.js:44_queryAlgolia @ app.js?hash=7e0101f…:13943search @ app.js?hash=7e0101f…:13867(anonymous function) @ app.js?hash=7e0101f…:13698later @ underscore.js:731
search:1 XMLHttpRequest cannot load https://LOLOLOLOL-dsn.algolia.net/1/indexes/songs-local/query. 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.
node.js:164 Uncaught TypeError: Cannot read property 'content-encoding' of undefinedresponse @ node.js:164g @ events.js:161EventEmitter.emit @ events.js:77(anonymous function) @ request.js:61EventEmitter.emit @ events.js:74Response.handle @ response.js:92xhr.onreadystatechange @ request.js:73
node.js:228 Uncaught TypeError: req.abort is not a function

We haved transistioned all our packages to npm now without any issues. Any ideas what could cause this issue? Is this again something with the browser setting? This seems to work as expected now.

@vvo
Copy link

vvo commented Jun 30, 2016

Hi @nerdmed, I am failing at understanding exactly the issue you are having.

This seems to work as expected now.

Do you mean everything works?

If you are using algoliasearch on the frontend with meteorjs, untill meteorjs fixes a bug in their require algorithm (meteor/meteor#6890), you will have to:

var algoliasearch = require('algoliasearch/src/browser/build/algoliasearch.js');

or

var algoliasearch = require('algoliasearch/src/browser/build/algoliasearchLite.js');

@nerdmed
Copy link
Author

nerdmed commented Jun 30, 2016

@vvo thanks a lot for your support! There was only a typo. The following works.

import algoliasearch from 'algoliasearch/src/browser/builds/algoliasearch.js';

Can you tell what explicitly is not working with the require algorithm as it seems not pretty clear in meteor/meteor#6890 ? Would be great to get some progress.

@nerdmed nerdmed closed this as completed Jun 30, 2016
@vvo
Copy link

vvo commented Jun 30, 2016

They need to implement the full browser spec of package.json here: https://github.com/defunctzombie/package-browser-field-spec

This is what is implemented by webpack and browserify.

It allows you to map not only the "main" field to something browser specific but multiple files to their browser builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants