Skip to content

TypeError: NetworkError when attempting to fetch resource. #95

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

Closed
TrianguloY opened this issue Oct 13, 2020 · 6 comments · Fixed by #96
Closed

TypeError: NetworkError when attempting to fetch resource. #95

TrianguloY opened this issue Oct 13, 2020 · 6 comments · Fixed by #96

Comments

@TrianguloY
Copy link
Contributor

TrianguloY commented Oct 13, 2020

When trying to fix the CORS error a few days ago, you made a change in the fetching code so now pages are fetched using fetch instead of fetchProxy.
adaa08a?branch=adaa08ac90758703e6294003b5a24a0e74286e17&diff=unified#diff-0f292e46fc1906eacb3fdbdaced082678d3b8d83fb44ab79b927d2abd836c358L107

Now, when using a page which has cors disabled, like dropbox, the service doesn't work.
http://htmlpreview.github.io/?https://www.dropbox.com/s/mgw65rktedx4pjl/Hello%20world.html?raw=1

Was that change a forgotten invalid fix? I recommend using fetchProxy again, so that dropbox links (and others) works again.

@niutech
Copy link
Collaborator

niutech commented Oct 13, 2020

This change was meant to lower the usage of CORS proxies and improve loading time, so that HTML documents from https://raw.githubusercontent.com could be fetched directly. I didn't realize that HTMLPreview is used outside of GitHub/Bitbucket, like with Dropbox. I will make an exception for such cases.

@TrianguloY
Copy link
Contributor Author

Ah, I understand.

Yes, a friend of mine uses the page with dropbox (https://jdelcastilloshideout.blogspot.com/2020/09/paravicini-y-la-roca-rodante.html) and asked me why the page stopped working, so I investigated and found the issue.

Thanks for the quick reply 😊. An exception is enough for my friend.

TrianguloY added a commit to TrianguloY/htmlpreview.github.com that referenced this issue Oct 16, 2020
When fetching a resource, try directly first. If it throws an error, then try with proxies.
Fixes htmlpreview#95
Should also reduce drastically the petitions to the proxy servers (will only be made if the non-proxy fails)
@TrianguloY
Copy link
Contributor Author

Sorry for the reply, but perhaps you have disabled notifications of pull requests.
I investigated the issue and found a solution that also should drastically reduce the number of petitions to the cors proxies. More info in the pull request: #96

You can check the result here:
https://trianguloy.github.io/htmlpreview.github.com/?https://www.dropbox.com/s/mgw65rktedx4pjl/Hello%32world.html?raw=1
https://trianguloy.github.io/htmlpreview.github.com/?https://github.com/twbs/bootstrap/gh-pages/2.3.2/index.html
https://trianguloy.github.io/htmlpreview.github.com/?https://github.com/documentcloud/backbone/blob/master/examples/todos/index.html

@peastman
Copy link

I also started encountering this error, but my file is on Github. Here's the file:

https://github.com/openmm/pdbfixer/blob/master/Manual.html

The following link produces the error message given above:

https://htmlpreview.github.io/?https://github.com/openmm/pdbfixer/blob/master/Manual.html

@peastman
Copy link

peastman commented Nov 9, 2020

Is there anything I can do to work around this problem?

@TrianguloY
Copy link
Contributor Author

@peastman The link you posted above (https://htmlpreview.github.io/?https://github.com/openmm/pdbfixer/blob/master/Manual.html) works fine for me. I checked the mentioned issue from your repo and the link is different. Simply update the link to this one and it will work again.

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

Successfully merging a pull request may close this issue.

3 participants