Skip to content

Commit

Permalink
Merge pull request #14 from Asvin1/master
Browse files Browse the repository at this point in the history
Added worker to fetch csv from dolthub
Asvin1 authored Oct 7, 2023

Verified

This commit was signed with the committer’s verified signature.
MoritzWeber0 Moritz Weber
2 parents 3f43364 + 5bb93a0 commit cafe01b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/csvworker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
async fetch(request) {
async function MethodNotAllowed(request) {
return new Response(`Method ${request.method} not allowed.`, {
status: 405,
headers: {
Allow: "GET",
},
});
}
// Only GET requests work with this proxy.
if (request.method !== "GET") return MethodNotAllowed(request);
var resp=await fetch(request.url.substring((request.url.toString()).lastIndexOf('.dev') + 5));
let response = new Response(resp.body, resp);
response.headers.set("Access-Control-Allow-Origin","*");
response.headers.append("Vary", "Origin");
return response;
},
};

0 comments on commit cafe01b

Please sign in to comment.