I’m running into an issue where ftplib can’t be used as a library inside of the py-env in the browser. It’s being blocked by cors.
“Access to fetch at ‘https://pypi.org/pypi/ftplib/json’ from origin ‘http://127.0.0.1:5500’ has been blocked by CORS policy: 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.”
You can go to https://actualseomediareports.web.app and see that the pyscript runs well when ftplib is not specified to be used in the browser. However when i’m trying to use ftplib to grab files from a server it hits me with a cors error. It isn’t because of my own server. The reason why I know it isn’t. Is because i’m using jupyter’s notebook on my computer to access the same server over ftplib and I get no errors.
Hi @coreytmayweather, and welcome to the forum! Interesting issue there - a couple of things to help us understand the issue better:
- Can you copy and paste your python and HTML files inside of a codeblock in this thread? That’s text ```surrounded by three backticks like this```, which makes it show up as a block of code, which we can copy/paste and try for ourselves instead of retyping the screenshots
- It looks like that firebase app hasn’t been published yet; this is what I see when I follow that link:
Here’s the github of everything.
You can load it up on vscode if you have live preview. The code in question is in the home.html. in the first “py-env”. If you go live with the server. and go to the console you can see that the ftplib will cause a cors issue.
Thank you for your help!
Apologies the website link is https://actualseomediareports.web.app, and it’s updated in the original post.
Thank you for your reply!