diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcab4dd..8311655 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: with: deno-version: v2.x - name: Run tests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: deno test --allow-env --allow-read=. --allow-net=api.github.com,0.0.0.0,localhost - name: Deploy to Deno Deploy uses: denoland/deployctl@v1 diff --git a/handleRequest.ts b/handleRequest.ts index ff3472a..4b19dfe 100644 --- a/handleRequest.ts +++ b/handleRequest.ts @@ -137,12 +137,12 @@ async function resolvePluginOrSchemaUrl(url: URL) { function getAccessControlAllowOrigin(request: Request) { const origin = request.headers.get("origin"); - return origin != null && isAllowedLocalHostname(new URL(origin).hostname) + return origin != null && isLocalHostname(new URL(origin).hostname) ? origin : "https://dprint.dev"; } -function isAllowedLocalHostname(hostname: string) { +function isLocalHostname(hostname: string) { return hostname === "localhost" || hostname === "127.0.0.1"; } @@ -158,7 +158,7 @@ function shouldDirectlyServeFile(request: Request) { } const hostname = new URL(origin).hostname; - return hostname === "localhost" || hostname === "dprint.dev"; + return isLocalHostname(hostname) || hostname === "dprint.dev"; } function createRedirectResponse(location: string) {