Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion handleRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ async function resolvePluginOrSchemaUrl(url: URL) {

function getAccessControlAllowOrigin(request: Request) {
const origin = request.headers.get("origin");
return origin != null && new URL(origin).hostname === "localhost"
return origin != null && isAllowedLocalHostname(new URL(origin).hostname)
? origin
: "https://dprint.dev";
}

function isAllowedLocalHostname(hostname: string) {
return hostname === "localhost" || hostname === "127.0.0.1";
}

function shouldDirectlyServeFile(request: Request) {
// directly serve for when Deno makes a request in order to fix the content type
if (request.headers.get("user-agent")?.startsWith("Deno/")) {
Expand Down