Skip to content
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

Add interceptors and proxies for dev server #661

Draft
wants to merge 8 commits into
base: next
Choose a base branch
from

Conversation

Dumeng
Copy link
Contributor

@Dumeng Dumeng commented Oct 8, 2021

Now, we can use yarn dev to start dev server

@Dumeng
Copy link
Contributor Author

Dumeng commented Oct 9, 2021

Now, we can only proxy the request seed by the axios. Audio and images retrieve by html elements directly cannot be handled.
We may need a global url replacer or a service worker to handle these request.
I will create another PR maybe later.

@mikelxk
Copy link
Collaborator

mikelxk commented Oct 13, 2021

I tested using service worker without https under localhost, it works just fine.
Do we really need the boresome certificate and CA stuffs to make it work?
image
Also we need to provide an alternative to set/get/delete cookies since the chrome.cookie only exists in extension

@Dumeng
Copy link
Contributor Author

Dumeng commented Oct 13, 2021

If it works fine, then the cert is not necessary. But in some cases, you will get error when you are try to load HTTPS url in a HTTP page.

@Dumeng
Copy link
Contributor Author

Dumeng commented Oct 13, 2021

If the current dev server solution is enough to support UI development. I'd like moving on the create a new local playlist based on indexed DB. The cookies issue will be deprioritized.

@mikelxk
Copy link
Collaborator

mikelxk commented Oct 13, 2021

If the current dev server solution is enough to support UI development. I'd like moving on the create a new local playlist based on indexed DB. The cookies issue will be deprioritized.

There's a builtin localforage currently uses indexDB in chrome extension, you might be interested in that as well.

@listen1
Copy link
Owner

listen1 commented Oct 15, 2021

very interesting pr to support dev in browser.

still testing it because it seems not working in my environment. (Mac, Chrome V93). It seems not easy for developers to setup. More docs may help. In my situation, console complains about this. I'm still try to figure out what does it mean.

An unknown error occurred when fetching the script.

:3000/#/:1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://localhost:3000/') with script ('https://localhost:3000/sw.ts'): An unknown error occurred when fetching the script.

I'm sure proxy port is running at port 3001.

@mikelxk
Copy link
Collaborator

mikelxk commented Oct 15, 2021

still testing it because it seems not working in my environment. (Mac, Chrome V93). It seems not easy for developers to setup. More docs may help. In my situation, console complains about this. I'm still try to figure out what does it mean.

I believe it's due to browser won't fetch service worker if the https certificate is not trusted. You can either trust the certificate or run vite without https because service worker still work under localhost.

@listen1
Copy link
Owner

listen1 commented Oct 15, 2021

still testing it because it seems not working in my environment. (Mac, Chrome V93). It seems not easy for developers to setup. More docs may help. In my situation, console complains about this. I'm still try to figure out what does it mean.

I believe it's due to browser won't fetch service worker if the https certificate is not trusted. You can either trust the certificate or run vite without https because service worker still work under localhost.

thanks. problem solved. Now in homepage it is working as expect.

But when you enter any playlist, or any function related to cookie API (we use chrome.cookie API), things broke. I think the reason is browser environment does not support chrome extension API, so if we need things work, in dev mode, we need to migrate chrome related api to dev server.

So I think this feature is still in experimental stage. The idea is good, more research is necessary.

@listen1 listen1 marked this pull request as draft October 15, 2021 08:59
@mikelxk mikelxk mentioned this pull request Oct 23, 2021
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 this pull request may close these issues.

3 participants