Comments (14)
Hey @ghostdevv I see Tauri added the requested feature! Does that mean this issue is no longer needed?
from tauri-update-cloudflare.
Probably not, however it might be good for people who don't wanna ship their gh token in their tauri app
from tauri-update-cloudflare.
I'm going to close this for now, but open to a new request or PRs!
from tauri-update-cloudflare.
Not to open up an old issue, but if any work is still being done on this I would also love to have a proxy server in here. I'd love to do it myself but cloudflare workers are not my forte. Would be super nice to have this though!
from tauri-update-cloudflare.
@ACPixel no worries, happy to take a look into it. Does the above describe your needs? is there anything not captured here that should be?
from tauri-update-cloudflare.
I think that the issue contains everything that would need to be there. Basically just a route to proxy the files, and would need to make sure the json responses contain links to the proxy instead of the release files directly.
from tauri-update-cloudflare.
@ACPixel @ghostdevv This is now merged and available! Proxying is enabled if a GITHUB_TOKEN
is set, please let me know how it works out for you!
from tauri-update-cloudflare.
Amazing! I'll try it out as soon as possible! Thanks again for taking and look and a huge thanks for doing that so quickly!
from tauri-update-cloudflare.
Alright got a chance to try it out, everything works as intended except one thing. The actual downloads don't work for private repos as it's trying to proxy the "browser_download_url" which only works via a valid github auth. Adding the auth headers and switching the url from the browser_download_url
to the url
on the release json fixes this issue as it then uses the release assets API to get the file.
I'm doing it like this since in my case I only need to handle the private github repo:
const getLatestAssets = async (request: Request) => {
const fileName = request.url.split("/")?.at(-1);
if (!fileName) {
throw new Error("Could not get file name from download URL");
}
const release = await getLatestRelease(request);
const downloadPath = release.assets.find(
({ name }) => name === fileName,
)?.url;
if (!downloadPath) {
throw new Error("Could not get file path from download URL");
}
const { readable, writable } = new TransformStream();
const headers = new Headers({
Accept: "application/octet-stream",
"User-Agent": request.headers.get("User-Agent") as string,
});
if (GITHUB_TOKEN?.length)
headers.set("Authorization", `token ${GITHUB_TOKEN}`);
const file_response = await fetch(downloadPath, {
method: "GET",
redirect: "follow",
headers,
});
file_response?.body?.pipeTo(writable);
return new Response(readable, file_response);
};
from tauri-update-cloudflare.
Ah that makes total sense, probably should have set up a private repo to test it fully 😃
Would you mind doing a PR with those changes? Glad you got it working!
from tauri-update-cloudflare.
Yeah can do. I have to clean up a couple things I put in while testing but I'll try to get one out tonight. Also had to update typescript version to get the .at() functions you used working.
from tauri-update-cloudflare.
@ACPixel I appreciate that, was attempting to do it pretty hastily and the repo definitely could use a little new years cleaning!
from tauri-update-cloudflare.
No problem! Sorry for the delay been a busy week, I'll try to get it cleaned up and ready within the next couple of days haha
from tauri-update-cloudflare.
Awesome! Managed to get this working today with some tweaks to the code
@ACPixel Did you manage to get some time to look at a PR? Lmk if you need any help
from tauri-update-cloudflare.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tauri-update-cloudflare.