AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 657 forks source link

CORS OneDrive & AlaSQL #537

Open tmrk opened 8 years ago

tmrk commented 8 years ago

I realise there already seem to have been a couple of questions regarding CORS or cross-domain linking, but I just can't seem to figure this out.

I am building a single-page web app, that uses an .xlsx file as a database. So far, the xlsx was in the same directory as the site, so access was not a problem.

However, for the final version, I would like to upload it to OneDrive, so that I can edit it online anytime, and AlaSQL loads it from there, always the latest version. I am using the following code for loading it:

alasql('SELECT * FROM XLSX("https://onedrive.live.com/download?resid=E9840C036A2225C!183&authkey=!AFKRWbFPVAhqdtI&ithint=file%2cxlsx",{headers:true})',
  [],function(database){

  // do stuff with my database

});

... I mean I would like use this, as right now it gives me a "No 'Access-Control-Allow-Origin' header is present" error, because of the different domains. (In the meantime, I keep the xlsx file in the same directory.

Unfortunately, I don't have any access to server settings in this project. The whole reason behind using a Javascript-based solution is that I cannot use any server functions where my HTML is stored.


Ps: The original link I got from OneDrive was: https://onedrive.live.com/redir?resid=E9840C036A2225C!183&authkey=!AFKRWbFPVAhqdtI&ithint=file%2cxlsx - but I figured if I change "redir" to "download" it give me a direct link. Still no luck with access though.

agershun commented 8 years ago

@tmrk Thank you!

I am going to use this approach:

For OneDirve:

For Dropbox:

For GitHub:

tmrk commented 8 years ago

@agershun re GitHub Pages: I just tried committing a version to my GitHub (where my page will eventually be shared) and when I open it from GH Pages, it gives the same error (No 'Access-Control-Allow-Origin'). I also found this answer: http://stackoverflow.com/a/26417091/4593394 regarding this.

mathiasrw commented 8 years ago

It does not solve your question, but I have a feeling it solves your problem: www.sheetsu.com

agershun commented 8 years ago

We already use Tabletop (https://github.com/jsoma/tabletop) to access Google Spreadsheets, but I will look at this Google API. Thank you!

2016-01-15 17:43 GMT+03:00 Mathias Rangel Wulff notifications@github.com:

I have a feeling you would love this: www.sheetsu.com

— Reply to this email directly or view it on GitHub https://github.com/agershun/alasql/issues/537#issuecomment-171977953.

agershun commented 8 years ago

BTW: We can write plugin with SHEETSU() function:

alasql('REQUIRE SHEETSU');
alasql('SELECT * INTO SHEETSU($0) FROM SHEETSU($0) WHERE a = 10',[sheetsuUrl]);

or (as we want to add earlier):

alasql('UPDATE SHEETSU(?) SET b = a*10 WHERE a = 10',[sheetsuUrl]);
mathiasrw commented 8 years ago

Love it. I think this are things that can create some publicity

tmrk commented 8 years ago

@mathiasrw thanks, Sheetsu really looks awesome, however, for this project I must use an .xlsx file that is either stored in OneDrive or Dropbox.

mathiasrw commented 8 years ago

@tmrk Dont know how to avoid the cross domain thing. Guess its a host vs. browser challenge (and not so much alasql it self)

tmrk commented 8 years ago

@mathiasrw you're probably right. However, it would be pretty awesome not having to worry about this when using alasql, wouldn't it? :) IF, of course, it's possible from the script side.

mathiasrw commented 8 years ago

Im closing the issue. If you find a way to get around it let us know reopen and we will incooperate it. If you have more questions just reopen the issue.

agershun commented 8 years ago

I did some tests with OneDrive, but still didnot succeed with this problem (one of the reason: OneDrive requires some authorization). I will play more with this in the week.

mathiasrw commented 8 years ago

:+1:

Fohroer commented 2 years ago

I realise there already seem to have been a couple of questions regarding CORS or cross-domain linking, but I just can't seem to figure this out. It's late but if anyone is in the same trouble please know that you can use https://cloudinary.com/ as CDN. It has no CORS limitations and has nice limits on free tariff.