sunsetsonwheels / webstore

Web client for BananaHackers store-db
https://store.bananahackers.net
GNU General Public License v3.0
17 stars 6 forks source link

Use the Github mirror, too. #7

Closed farooqkz closed 3 years ago

farooqkz commented 3 years ago

Is your feature request related to a problem? Please describe. Users with an IP address from Iran and probably many other countries like China cannot use this store(practically)

Describe the solution you'd like Use the Github mirror if you couldn't access Gitlab after a try or two.

sunsetsonwheels commented 3 years ago

It does use the GitHub mirror, here: https://github.com/jkelol111/webstore/blob/master/src/assets/js/index/workers/store-worker.js#L9

farooqkz commented 3 years ago

Yeah you have done. I just looked into Network tab and I noticed it sends an "OPTIONS" request to the server and the Github mirror sends "405 Method Not Allowed" and your software doesn't seem to handle that(At least I never see a list of apps).

Another thing is that you are using the old URL of mirror which is still working but it is recommended that you use the new one which its link is in my first post.

If you let me, I can send a PR.

sunsetsonwheels commented 3 years ago

I have tried changing it to the new mirror in the latest commit.

farooqkz commented 3 years ago

Please read my last message again. That might not be enough.

sunsetsonwheels commented 3 years ago

Did you run this from localhost, or is it running live on the server? If I'm not mistaken, this is a CORS issue.

farooqkz commented 3 years ago

I am trying https://jkelol111.github.io/webstore which redirects to store.bananahackers.net

I will soon send you more debug information from Network and Console tabs and possibly send a PR.

sunsetsonwheels commented 3 years ago

Sure.

farooqkz commented 3 years ago

I figured out why this happens but I don't know how to fix it. There are 2 problems here:

  1. A request is sent to Gitlab for data.json but it waits too long time and then it switches to Github. I suggest setting a timeout value. 5-10 seconds seem reasonable.
  2. After the default timeout is reached, an OPTIONS request is sent to Github and it responses with 405 Method not Allowed.

After digging into source code(https://github.com/jkelol111/webstore/blob/master/src/assets/js/index/workers/store-worker.js#L100), I realized that you use GET rather than OPTIONS so that's why I don't know where the problem is.

(BTW, in README.md replace "shangul" with "Farooq Karimi Zadeh")

farooqkz commented 3 years ago

I can give you ssh access to my NanoPi in Iran so that you can setup a simple proxy there and test and see for yourself. The internet connection is however so creepy at the moment.

sunsetsonwheels commented 3 years ago

I found this: https://stackoverflow.com/questions/8153832/xmlhttprequest-changes-post-to-option

This is probably a CORS issue between *.github.io domains (I have had this happen in OpenRevise 2, another project of mine).

Will change the name for you in the README.md file :)

farooqkz commented 3 years ago

So what are you going to do to solve this problem?

farooqkz commented 3 years ago

How about this? https://en.wikipedia.org/wiki/JSONP#Script_element_injection

It is said that it's unsafe in general but we are sure about the data we have since we generate it ourselves.

farooqkz commented 3 years ago

@jkelol111 You have forgotten to do this:

gulp
git add docs
git commit -m "build"
git push
sunsetsonwheels commented 3 years ago

I already did build it in a separate commit.