https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • j

    James

    12/07/2020, 1:53 AM
    mapRequestToAsset
    doesn't fire for assets that exist in the
    ASSET_MANIFEST
    - they're always served directly from KV. In an older version of
    kv-asset-handler
    , this used to work as per https://github.com/cloudflare/kv-asset-handler/blob/ce0229fe54e38728b2d7796646e20a05ea23b6d1/src/index.ts#L98, which always used
    mapRequestToAsset
  • j

    James

    12/07/2020, 1:54 AM
    Unless I'm misunderstanding what you're saying? As per https://github.com/cloudflare/kv-asset-handler/blob/3228cd78de1f4f61d74cecb13a3b19054d67d501/src/index.ts#L104-L110 though, this function is never fired if the asset exists in the manifest. So if I have a
    jpg
    ,
    webp
    and
    avif
    in the manifest, and someone requests the
    jpg
    , there's no simple way to programatically serve the
    avif
    (such as in a CSS
    background-image
    ), as far as I can tell.
  • i

    itsmatteomanf

    12/07/2020, 2:00 AM
    Oh, yeah you are right... if it only allowed to pass in only the request. They need the full event for a waitUntil, but couldn't you simply copy the event and modify the URL? It's not the best, but might work.
  • j

    James

    12/07/2020, 2:09 AM
    Is there an API I'm not aware of to clone and modify a
    FetchEvent
    like that? Trying to reconstruct a
    FetchEvent
    myself to hackily work around this throws a
    Illegal constructor
    error 😦
  • i

    itsmatteomanf

    12/07/2020, 2:10 AM
    Never tried and never sure it even works... if you are on Business and up you could use the Image Resizer from CF.
  • j

    James

    12/07/2020, 2:13 AM
    Yeah that's probably an option with
    format=auto
    and
    format=avif
    . I'd prefer to statically do this though on my very static Workers sites,. Hopefully there'll be a resolution on this issue. This definitely used to be possible in older versions of
    kv-asset-handler
    , but was originally changed in https://github.com/cloudflare/kv-asset-handler/commit/c97b8ddf118b8711bc1cc9408461a1c47a1843be it seems.
  • j

    James

    12/07/2020, 2:14 AM
    I've no idea on the full scope of why
    mapRequestToAsset
    couldn't be called on every request if it's explicitly passed into
    options
    - it would seem logical to me to allow this.
  • i

    itsmatteomanf

    12/07/2020, 2:16 AM
    Yeah, this.
  • i

    itsmatteomanf

    12/07/2020, 2:22 AM
    Maybe @User or @User know who to ask for this. Or maybe we can even open a pull request ourselves.
  • j

    James

    12/07/2020, 2:25 AM
    I'd happily create a PR and even add some tests for this if it makes sense. I just want to make sure I understand the impact. From what I can tell, it should be pretty simple to tweak the
    getAssetFromKV
    function, switch up the
    Object.assign
    at the top for defaults, handling `mapRequestToAsset`'s default more manually. And then below when assigning
    requestKey
    , check if
    options.getAssetFromKV
    was explicitly passed in (not from default), and if so use that, else do the existing behaviour.
  • r

    Rodney

    12/07/2020, 2:26 AM
    for 5,600,000,000 requests per/month you said "Those are 25k+$/month," - isn't at $0.5 per 1m = ~2.8k $/m
  • i

    itsmatteomanf

    12/07/2020, 2:27 AM
    Oh, yeah! You are totally right... I did that in my head and used the 5 without diving by ten. The rest of the suggestion still stands, contact sales.
  • c

    catgirl

    12/07/2020, 4:14 PM
    @User Is there a way to bypass the domain registratino check on cloudflare?
  • c

    catgirl

    12/07/2020, 4:14 PM
    I just registered a name and want to get it provisioned by cloudflare isn't seeing it yet
  • a

    albert-zhao

    12/07/2020, 4:15 PM
    You mean using the Cloudflare Registrar?
  • c

    catgirl

    12/07/2020, 4:15 PM
    It was registered externally
  • c

    catgirl

    12/07/2020, 4:15 PM
    it's being managed for a customer, not my name
  • c

    catgirl

    12/07/2020, 4:15 PM
    paste.cx
  • c

    catgirl

    12/07/2020, 4:15 PM
    it even points to my cloudflare nameservers
  • c

    catgirl

    12/07/2020, 4:15 PM
    dara and micah
  • c

    catgirl

    12/07/2020, 4:16 PM
    Copy code
    Domain Name: paste.cx
    Registry Domain ID: 1862755-CoCCA
    Registry WHOIS Server:: whois.coccaregistry.org
    Updated Date: 2020-12-07T16:11:19.712Z
    Creation Date: 2020-12-07T16:07:54.36Z
    Registry Expiry Date: 2021-12-07T16:07:54.99Z
    Registrar Registration Expiration Date: 2021-12-07T16:07:54.99Z
  • a

    albert-zhao

    12/07/2020, 4:17 PM
    yeah I'm not sure our team can answer about the Registrar. It looks like it can take up to 15 days for this process to complete? https://support.cloudflare.com/hc/en-us/articles/360019910671-Transferring-and-renewing-domains-with-Cloudflare-Registrar#:~:text=Transfer%20a%20domain%20to%20Cloudflare,-Refer%20to%20the&text=A%20transfer%20takes%20up%20to,release%20of%20the%20domain%2C%20and
  • c

    catgirl

    12/07/2020, 4:17 PM
    No I'm not transfering it
  • c

    catgirl

    12/07/2020, 4:17 PM
    I just mean adding it to my cloudflare account for dns and cdn
  • c

    catgirl

    12/07/2020, 4:18 PM
  • a

    albert-zhao

    12/07/2020, 4:18 PM
    o gotcha, sometimes that can take up to 48 hours
  • i

    itsmatteomanf

    12/07/2020, 4:18 PM
    It's been just registered, it needs to propagate. Give it a couple hours at least.
  • i

    itsmatteomanf

    12/07/2020, 4:20 PM
    Also, never point domains to Cloudflare nameservers prior to adding them, it will cause you issues, especially with some registrars and some TLDs.
  • c

    catgirl

    12/07/2020, 4:23 PM
    Wait really? I've never had issues before doing that
  • i

    itsmatteomanf

    12/07/2020, 4:25 PM
    Yeah, sometimes Cloudflare's systems recognise it as trying to hijack it, causing them to issue different nameservers (there are no user NS, those are always per domain, which tend to stay the same unless something changes). Some registrars then require the new ones to respond with the correct ones, but Cloudflare won't since it sees the old ones and you need to ask support. Seen it soooo many times in the Community.
1...141516...2509Latest