-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Cross-Origin request blocked using multi-user setup #81
Comments
Hi @jmformenti, it should be possible to use wikibase-edit in the browser since #47, but I don't use that possibility and we don't have tests to assert that unfortunately. Maybe @SirkoS knows more about the topic? Reading mediawiki docs on CORS, it seems we might be missing the possibility to pass an Could you try to set that |
Thanks @maxlath, I've realized that the failing request is this one: I've added
My guess is that this is a special request precisely to get CSRF tokens and maybe |
The issue is that wb-edit does not add the origin parameter when making requests to the Wikibase API. In a node.js environment this does not matter, but in the browser, the CORS header in the response must match (security). const addOrigin = (url, origin) => {
const urlObj = new URL(url)
urlObj.searchParams.set('origin', origin)
return urlObj.toString()
} There is also another issue when trying to make wb-edit work in the browser: cookie management. In the browser, it is not possible to manage cross-site cookies (security). I replaced cross-fetch with axios to use a cookie jar, which essentially handles all the cookies automatically. I'm sure there are better solutions, but for now, it works. I created a fork, which runs fine in the browser now. However, I haven't tested it with Node.js yet. Furthermore, for node.js, the origin header is hard-coded (laziness) in fetch.js. For the browser, the origin is automatically pulled from Fork: https://github.com/AlexW00/wikibase-edit |
Thanks a lot @AlexW00, I'm trying to use your fork but I'm getting the same error, not sure if I'm doing something wrong.
In order to make it work in my case (a VUE application with client side rendering) I needed to change this line: https://github.com/AlexW00/wikibase-edit/blob/main/lib/request/client.js#L1 for: |
What does |
I've double-checked it, the
And this is my config in Wikibase:
My Wikibase version is 1.36.4. |
In your wbEditConfig object, the port of your wikibase instance seems to be missing. On which port is wikibase running? If it is this.wbEditBrowser = require('wikibase-edit-browser')({
instance: 'http://localhost:8181',
credentials: {
username: 'admin',
password: 'XXX'
}
})
this.wbEditBrowser.label.set({ id: 'Q35702', language: 'ca', value: 'test' }) |
It is running on port 80, I'll try to upgrade Wikibase to discard some problem with that version |
We are working on a VUE application (client side rendering) to manage our own Wikibase instance and we want users to login using our application with OAuth.
We have our OAuth authentication process against Wikibase implemented and got access tokens properly but when we try to execute our first action with wikibase-edit:
we got this error:
We are following this documentation: https://github.com/maxlath/wikibase-edit/blob/main/docs/how_to.md#multi-user-setup
What are we doing wrong? Can wikibase-edit be used from javascript running in the browser?
The text was updated successfully, but these errors were encountered: