https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • g

    geelen

    11/26/2021, 12:07 PM
    does
    functions/index.js
    not work?
  • t

    The Freelancer ;)

    11/26/2021, 12:10 PM
    not tried it
  • t

    The Freelancer ;)

    11/26/2021, 12:11 PM
    what's the build command supposed to be? just
    npm i
    ?
  • e

    eidam | SuperSaaS

    11/26/2021, 12:20 PM
    functions build automatically, the build command is for your static files
  • t

    The Freelancer ;)

    11/26/2021, 12:20 PM
    oh
  • t

    The Freelancer ;)

    11/26/2021, 12:20 PM
    I set it as
    npm i
  • t

    The Freelancer ;)

    11/26/2021, 12:20 PM
    silly me πŸ˜„
  • t

    The Freelancer ;)

    11/26/2021, 12:21 PM
  • t

    The Freelancer ;)

    11/26/2021, 12:21 PM
    now to try it
  • t

    The Freelancer ;)

    11/26/2021, 12:27 PM
    waheyyyyy
  • t

    The Freelancer ;)

    11/26/2021, 12:27 PM
    πŸ˜„
  • t

    The Freelancer ;)

    11/26/2021, 12:28 PM
    @User thank you πŸ˜„
  • t

    The Freelancer ;)

    11/26/2021, 12:29 PM
    does it count the functions requests separately from worker requests?
  • e

    Erisa | Support Engineer

    11/26/2021, 12:33 PM
    at the moment it does, no clue what will happen in future
  • t

    The Freelancer ;)

    11/26/2021, 12:33 PM
    its not an issue anyway πŸ˜„
  • t

    The Freelancer ;)

    11/26/2021, 12:43 PM
    you do need the build command as
    npm i
  • t

    The Freelancer ;)

    11/26/2021, 12:43 PM
    I removed it and it won't deploy
  • t

    The Freelancer ;)

    11/26/2021, 1:37 PM
    is there an example of how to redirect the default pages domain to somewhere while allowing custom domains through without using Cloudflare Access?
  • e

    eidam | SuperSaaS

    11/26/2021, 1:42 PM
    I am not aware of any example for this use-case, but you have access to the request object in Functions, so you can redirect specific hostnames, or any other hostnames than your custom domains.
  • t

    The Freelancer ;)

    11/26/2021, 1:43 PM
    thank you
  • t

    The Freelancer ;)

    11/26/2021, 1:50 PM
    will get it right eventually, I must have broken it because the function script is throwing an exception πŸ˜„
  • t

    The Freelancer ;)

    11/26/2021, 1:57 PM
    let's see what happens when this latest build finishes
  • t

    The Freelancer ;)

    11/26/2021, 2:00 PM
    waheyyyyy
  • t

    The Freelancer ;)

    11/26/2021, 2:00 PM
    πŸ˜„
  • m

    Marcelino Franchini

    11/26/2021, 8:59 PM
    Cross-domain redirection is not yet implemented, it will give you this error "Only relative URLs are allowed. Skipping absolute URL", to avoid SEO penalties for not redirecting duplicate content we use the _header file: https://example.pages.dev/* Link: ; rel="canonical" Refresh: 0; url=https://example.com/:splat
  • t

    The Freelancer ;)

    11/26/2021, 8:59 PM
    thanks
  • t

    The Freelancer ;)

    11/26/2021, 8:59 PM
    I managed to do it using functions anyway πŸ™‚
  • t

    The Freelancer ;)

    11/26/2021, 9:00 PM
    Copy code
    javascript
    export async function onRequest(context) {
        // Contents of context object
        const { request, env, params, waitUntil, next, data, } = context;
        const url = new URL(request.url);
        const destinationURL = "https://" + env.REDIRECT_URL;
        const statusCode = 302;
    
        if (url.hostname.endsWith(".pages.dev")) { 
            return Response.redirect(destinationURL, statusCode);
        }
        
        return next()
    }
  • t

    The Freelancer ;)

    11/26/2021, 9:00 PM
    is how I did it
  • z

    zve8

    11/26/2021, 11:38 PM
    I am excited to use stripe in combination with the new pages functions setup. However am I missing something or is there no way for me to bundle the stripe library using the
    ./functions
    file structure bundler? I see I could do a custom advanced usage bundle (
    _workers.js
    ) but then there would be a function invocation for every asset call.
1...212223...392Latest