rlach/wiki-import

CORS Permsision

Closed this issue · 4 comments

Tried to import across multiple wiki sites, and run into the following error in console

Access to fetch at 'https://pathfinderwiki.com/api.php?action=query&prop=revisions%7Cpageprops&rvprop=content&maxlag=5&rvslots=main&origin=*&format=json&redirects=true&titles=Minata' from origin 'http://localhost:30000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

rlach commented

That's is unfortunately something that cannot be avoided with some wiki sites, pathfinderwiki being one of them. This is because javascript run from a browser, which includes all foundry modules, is bound by CORS policies for safety purposes. It cannot be opted out.

Fortunately you can still import from pathfinderwiki(and most others that fail with this error) with few additional steps.

On the wiki site choose "View source"
Zrzut ekranu 2021-08-30 o 11 37 31

There you can copy everything from this box:
Zrzut ekranu 2021-08-30 o 11 38 19

Finally in the import window paste the source you just copied, and fill in the wiki name, like this:
Zrzut ekranu 2021-08-30 o 11 43 58
Be sure to leave first field empty!

You have to fill Wiki domain only once, it will remember last selection for future pages.

rlach commented

@Clementinagurjar I'm sorry, this doesn't seem to be a wikipedia article link. Are you sure you posted it at right repo?

rlach commented

I've added more info on CORS in the module and on the wiki https://github.com/rlach/wiki-import/wiki/About-CORS

I hope those are a help to you and make the module easier to use.