TeamPiped / Piped-Docker

MIT License
39 stars 32 forks source link

Calls to fonts.kavin.rocks #3

Closed LivingWithHippos closed 2 years ago

LivingWithHippos commented 2 years ago

It's a little thing, but I was checking the network calls since I had some issues and noticed that some stuff it's loaded from ther

GET /s/materialiconsround/v65/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmM.otf HTTP/3
Host: fonts.kavin.rocks
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Origin: https://myserver.com
Connection: keep-alive
Referer: https://myserver.com
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
DNT: 1
Sec-GPC: 1
Pragma: no-cache
Cache-Control: no-cache

I get two calls, for /s/materialiconsround/v65/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmM.otf and /s/roboto/v27/KFOmCnqEu92Fr1Mu4mxP.ttf

FireMasterK commented 2 years ago

I'm not sure what's a good solution for this, fonts.kavin.rocks is basically a worker hosted on Cloudflare Workers with the following source code:

addEventListener('fetch', function(event) {
  const { request } = event
  const response = handleRequest(request)
  event.respondWith(response)
})

/**
 * Receives a HTTP request and replies with a response.
 * @param {Request} request
 * @returns {Promise<Response>}
 */
async function handleRequest(request) {

  const { pathname } = new URL(request.url);

  return fetch("https://fonts.gstatic.com" + pathname,  {
    cf: {
      cacheTtl: 31536000,
      cacheEverything: true,
    },
  });
}

All it does is forward requests to fonts.gstatic.com to prevent connections to google fonts.

If you do have a solution, let me know! I will re-open this issue then. I feel that creating an A record just for this is a bit overkill.