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

Retrieve the revision #203

Open
lpatiny opened this issue Jan 18, 2019 · 4 comments
Open

Retrieve the revision #203

lpatiny opened this issue Jan 18, 2019 · 4 comments

Comments

@lpatiny
Copy link
Member

lpatiny commented Jan 18, 2019

It should be possible to make this kind of query:

let url='https://mydb.cheminfo.org/db/eln/entry/b8d44e7857fac800ae119b7671a9c9f3';

let result=await fetch(url, {
	method: 'HEAD',
    mode: 'cors',
    credentials: 'include',
});
console.log(result.headers);

When in all the cases the result.headers is empty while in the network console the ETag containing the revision is correctly return.

It could be related to CORS and I also tried to add on the server the following line:

Header set Access-Control-Allow-Headers "ETag, Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"

In all my trials the result.headersis an empty object.

Any idea what I'm doing wrong ?

The goal here is to implement a monitoring system to warn the end-users when there is a new revision on the server.

@targos
Copy link
Member

targos commented Jan 18, 2019

This query is not possible in roc and wouldn't be much more efficient than a normal GET because we need to do a full query for permissions

@lpatiny
Copy link
Member Author

lpatiny commented Jan 18, 2019

In the API documentation there is:

HEAD | /db/:dbname/entry/:uuid | Get HTTP headers about the document | Similar to HEAD /:dbname/:docid in CouchDB

And if I check the network connection in the browser I really retrieve my ETag (revision of couchdb). It is just that from javascript I never could retrieve the header field.

Do you think there should be an new url like:

/db/:dbname/entry/:uuid/_rev

to retrieve revision ?

@targos
Copy link
Member

targos commented Jan 19, 2019

Please read the documentation of fetch. The headers object is not what you think. I confirm result.headers.get('etag') returns the expected value

@targos targos closed this as completed Jan 19, 2019
@lpatiny
Copy link
Member Author

lpatiny commented Jan 21, 2019

Actually it was not working with cors but I finally found the solution. You need to add in the header an 'Access-Control-Allow-Headers' entry.

Header set Access-Control-Allow-Headers "ETag"

I changed this on our server and it works correctly now.

@targos targos reopened this Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants