https://discord.cloudflare.com logo
Join Discord
Powered by
# pages-help
  • Does pages only work locally? Page only works when in the same network
    w

    Walshy | Pages

    04/28/2023, 5:56 PM
    what does "doesn't work" mean?
    m
    s
    • 3
    • 9
  • Cloudflare Pages Function CORS error
    j

    JavaDad

    04/28/2023, 9:24 PM
    I can not seem to get the CORS headers to allow all origins on one specific function. I have followed the examples in the docs but seems I still have something wrong. Any suggestions?
    Copy code
    typescript
    import { checkStoreSupportCode } from '../helpers/pocketbaseApi';
    
    export function onRequestOptions() {
        return new Response(null, {
            status: 204,
            headers: {
                'content-type': 'application/json;charset=UTF-8',
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Methods': 'GET, HEAD, POST, OPTIONS',
                'Access-Control-Allow-Headers': '*',
            },
        });
    }
    
    export async function onRequest({ request, env }) {
        if (request.method !== 'POST') {
            return new Response('Method not allowed', { status: 405 });
        }
    
        const { supportCode } = await request.json();
    
        if (!supportCode) {
            return new Response('Missing support code', { status: 400 });
        }
    
        try {
            const { status, error, storeHash } = await checkStoreSupportCode(supportCode, env);
            if (error) {
                return new Response(JSON.stringify({ status, error }));
            }
            return new Response(JSON.stringify({ status, storeHash }));
        } catch (err) {
            console.log(err);
            return new Response(JSON.stringify({ status: 'error', error: 'An unknown error occured' }));
        }
    }
    h
    • 2
    • 3
  • Could not resolve "node:buffer"
    d

    Dio

    04/29/2023, 2:47 PM
    trying to deploy next.js application Build command: npx @cloudflare/next-on-pages@beta --experimental-minify Build output directory: /.vercel/output/static
    s
    • 2
    • 14
  • is it possible to replace the pages.dev url everywhere on the page?
    m

    MiikaU

    04/29/2023, 5:00 PM
    Now the main page is my own domain, but when i click a link to navigate away from the front page it goes back to the pages.dev url. I think in GitHub pages, it automatically replaced the url everywhere with your custom domain, is it possible with cloudflare pages?
    h
    • 2
    • 9
  • Are you able to cancel your most recent build using Cloudflare Pages API?
    h

    Hubchicken

    04/30/2023, 12:17 AM
    Ive recently transferred from netlify to cloudflare, and I have a command on my bot to cancel the most recent build from netlify if its status was "Building". Since I've moved, I would like to know if you are able to do the same thing on Pages.
    w
    • 2
    • 2
  • Notification when deployment fails?
    i

    IEatBeans

    04/30/2023, 7:11 AM
    Hey, I just noticed that all my deployments from the last 15 days have been silently failing... That explains a lot about the weird issues I kept seeing in prod but not in dev... I only just checked the CF dashboard and fixed the issue right away, but I would have expected to receive an email or something when they fail. Is there a way to turn this on? Thanks!
    w
    • 2
    • 2
  • Handle OPTIONS requests only for CORS in pages' functions
    n

    narumi

    04/30/2023, 9:56 AM
    I have deployed a static site on pages, ideally only GET requests are used in clients. And I have set CORS headers in
    _headers
    . Some browsers such as Firefox will positively send OPTIONS preflight for CORS. However, pages will response with 405 Method Not Allowed error. The only solution I found is to add a middleware function to handle OPTIONS, but it will handle EVERY request, which is not desired. So I wonder whether there is a way to handle OPTIONS requests only in functions, don't handle GET. Or settings somewhere I can turn on allowing CORS preflight. Thanks.
    _headers
    Copy code
    /*
      Access-Control-Allow-Origin: *
      Access-Control-Allow-Methods: *
      Access-Control-Allow-Headers: *
    
    /*.json
      Content-Type: application/json; charset=utf-8
    functions/_middleware.js
    All OPTIONS/GET requests will be handled by workers, and daily usage limit is easily reached. https://developers.cloudflare.com/pages/platform/functions/examples/cors-headers/
    Copy code
    export const onRequestOptions: PagesFunction = async () => {
      return new Response(null, {
        status: 204,
        headers: {
          'Access-Control-Allow-Origin': '*',
          'Access-Control-Allow-Headers': '*',
          'Access-Control-Allow-Methods': 'GET, OPTIONS',
          'Access-Control-Max-Age': '86400',
        },
      });
    };
    h
    • 2
    • 9
  • If you cancel a Pages build, does it still count to your 500 total builds per month?
    h

    Hubchicken

    05/01/2023, 2:05 AM
    For example, If I have 10 builds left, I edit something on my github repo and cancel the build, does it go from 10 to 9 builds or does it remain at 10?
    w
    • 2
    • 15
  • ⚡▲ @cloudflare/next-on-pages ▲⚡ - Where to see the logs in case of Internal Server Errors?
    a

    avalizadeh

    05/01/2023, 12:10 PM
    I'm experimenting next js on pages but after successful build and deployment I get internal server errors, I cannot find a place to see the logs or to check whats happening....
    b
    • 2
    • 1
  • Getting error while doing git clone submodule
    s

    snaked

    05/01/2023, 12:11 PM
    I have a repo which has 2 git submodules, when trying to deploy it from the cloudflare pages it is unable to clone those submodules and giving error like "fatal: could not read Username for 'https://github.com': Input/output error" but both those repo are under the same org from which i am cloning from i.e i am deploying the repo company/A and the other repos are company/B and company/C , cloudflare is able clone the deployment product i.e A but not able to clone B and C . When i gave my access token in submodule path for B and C then it was able to clone it out and deployment worked, but i dont want to put the token in .gitmodules due to security concerns. Any idea on how to fix this and maybe add the security token to the environment variables of cloudflare pages
    s
    • 2
    • 2
  • next-on-pages and modifying routes
    b

    bret_pat

    05/01/2023, 8:51 PM
    So I only want page functions to run whenever I hit my nextjs API route, how can I do this?
    b
    • 2
    • 8
  • Error 8000036
    c

    cedrick1227

    05/02/2023, 1:42 AM
    Hi guys, I have encountered this error message "account has been blocked. Contact abusereply@cloudflare.com.", I already emailed it to the mentioned email address. I would like to know what could be the problem of my account. Pages is really important to me, as I use this for deployment of my personal projects. I would appreciate any help to overcome this. thanks,
    c
    • 2
    • 1
  • Could not resolve "node:buffer" [next-on-pages]
    d

    Durian Gray

    05/02/2023, 4:32 AM
    Hi, I've recently started getting this error on my preview and production deployments. I've read the other related posts on this Discord and have taken action based on those posts, but haven't been able to fix them. I've added some context on my build command and compatibility flags in the images. The error started showing up even for builds that were passing a couple days ago when I re-run them. If anyone can advise how I might fix this, it would be greatly appreciated. The relevant logs are as follows:
    Copy code
    21:24:05.515    ⚡️ Completed `pnpx vercel build`.
    21:24:08.831    ⚡️ Generated '.vercel/output/static/_worker.js'.
    21:24:12.438    Finished
    21:24:12.439    Found _worker.js in output directory. Uploading.
    21:24:13.460    ✘ [ERROR] 1 error(s) and 0 warning(s) when compiling Worker.
    21:24:13.461    
    21:24:13.462    
    21:24:13.465    
    21:24:13.467    ✘ [ERROR] Could not resolve "node:buffer"
    21:24:13.468    
    21:24:13.468        _worker.js:2:4194:
    21:24:13.468          2 │ ...ar ed={};import*as A_ from"node:buffer";var G5=Pt(()=>{Ce();$e()...
    21:24:13.468            ╵                              ~~~~~~~~~~~~~
    21:24:13.468    
    21:24:13.468      The package "node:buffer" wasn't found on the file system but is built into node.
    21:24:13.468      Add "node_compat = true" to your wrangler.toml file to enable Node compatibility.
    21:24:13.468    
    21:24:13.469    
    21:24:13.470    ✘ [ERROR] Build failed with 1 error:
    21:24:13.470    
    21:24:13.471      _worker.js:2:4194: ERROR: Could not resolve "node:buffer"
    21:24:13.471    
    21:24:13.471    
    21:24:13.485    Failed building Pages Functions.
    21:24:14.392    Failed: an internal error occurred
    b
    • 2
    • 4
  • How to configure environment variables with page direct upload
    a

    amit13

    05/02/2023, 3:34 PM
    I am trying to use direct upload to deploy a project in pages.
    Copy code
    CLOUDFLARE_ACCOUNT_ID=<ACCOUNT_ID> npx wrangler pages publish <DIRECTORY> --project-name=<PROJECT_NAME>
    How can i set the production environment variables at the time of deployment ?
    w
    • 2
    • 3
  • Getting `Uncaught ReferenceError: navigator is not defined` with remix deployment
    a

    agarwalviraj

    05/02/2023, 7:00 PM
    My remix project deployed on pages was working fine until yesterday when it suddenly stopped building successfully, now even the old commits don't get deployed successfully even though they are built. I am getting
    Uncaught ReferenceError: navigator is not defined
    each and every time, how should I fix this? Thanks in advance.
    j
    h
    • 3
    • 6
  • Configure headers
    k

    kulotskinakalbo

    05/03/2023, 1:38 PM
    whats the proper header rule for noindex of all PDF files using X-Robots-Tag?
  • Custom Branch Domain with Cloudflare Access fails
    f

    F0rce

    05/03/2023, 5:00 PM
    Hello everyone 🙂 As the title already says, if I want to access a preview deployment secured by Cloudflare Access. My branch on GitHub is called
    dev
    so I called the custom domain
    dev.<mydomain>
    - as soon as I visit
    dev.<mydomain>
    I have to enter my email and I receive a one-time-pin to access to preview deployment. As soon as I enter the pin I am redirected to a site with an error. Better said I am redirected to an 404 because the wierd url is not found (see attached screenshot). Accessing the deployment via its hash or the "normal"
    pages.dev
    url seems to work completely fine. Am I doing something wrong ? Thanks, David
    w
    • 2
    • 19
  • The script will never generate a response
    i

    iamawacko

    05/04/2023, 4:51 AM
    I've been trying to run a website built with sveltekit on Cloudflare pages, but after https://github.com/iamwacko/translated-website/commit/b52a1e0a52e2480ba735e420e78ebcff369a3558 all I get is error code 1101 and
    the script will never generate a response
    in the logs. translated-website.pages.dev is the site, 01d53951-87de-4bc3-b18a-dd41e4799e6c is the deployment ID of the first failure, and my account ID is 3f360bad2082c7f61e0746eed6acfe55.
  • Custom Hostname for Cloudflare Pages
    r

    rlnd

    05/04/2023, 12:59 PM
    We have a CNAME record i.e. page.example.com which points to foo.pages.dev. We also added page.example.com as Custom Domain to our foo.pages.dev page. Should it be possible to add a Custom Hostname with page.example.com as origin? Or is this setup impossible?
    b
    • 2
    • 1
  • Need help choosing the right framework for a custom Deny page for Cloudflare Access
    s

    Simon Thorpe (securitypedant)

    05/04/2023, 4:37 PM
    I am configuring multiple applications behind Cloudflare Access (https://developers.cloudflare.com/cloudflare-one/applications/configure-apps/). For each app, I can have a custom Deny URL when users are not granted access to the app. I want to host a site in Pages to serve that Deny URL page. I want to build a nice website that shows a highly customized, branded deny page. Because I can have this page for several apps, I want to pass in the app name/id on the query string to the page and have it modify the deny message based on the name/id. Or I could use a path on the URL to dynamically change the page content. So I could either... https://my.domain.com/deny?appname=jira&appid=10 or https://my.domain.com/deny/jira/10 Usually I would use Python/Flask and write this in server side code, but it seems Pages is all about front-end apps, no server side execution. So I could simply write this all in Javascript and have the client modify the page look and feel based on the app being denied. Given the HUGE number of frameworks I can choose from, https://developers.cloudflare.com/pages/framework-guides/. I'm looking for advice on which to start with. Anyone able to give me some guidance?
    k
    h
    • 3
    • 18
  • forever building
    s

    shapeshifter

    05/04/2023, 5:30 PM
    added cloudflare pages to the github repo and then removed it mid build. Will this eventually resolve on it's own. There doesn't appear to be a way to manually turn this off.
    k
    w
    • 3
    • 12
  • ⚡ The following functions were not configured to run with the Edge Runtime:
    s

    shapeshifter

    05/04/2023, 5:56 PM
    i think i'm not able to build because of functions in an /api/ folder (not /pages/api). They're not configured as edge api routes because they're intended to be called from the client side. Would this make sense?
    b
    • 2
    • 24
  • CORS error for analytics
    p

    peter-lustig

    05/04/2023, 7:59 PM
    I built a site with a static site generator (astro) and then deploy it with cloudflare pages which is connected to a github repo and runs npm run build. Can I somehow avoid these errors? I enabled analytics, and it seems to cause some issues.
  • getting 404 after fresh deploy to pages
    s

    shapeshifter

    05/04/2023, 9:09 PM
    When I run the next.js app locally I have no problems but on pages I get 404 for all pages that work locally
    b
    • 2
    • 19
  • Cloudflare Image resizing giving error 9524
    d

    DaveJ

    05/04/2023, 9:47 PM
    I am using Cloudflare Image Resizing but it has stopped working for some URLs recently. Here is an example URL that is now broken:

    https://next.todesktop.com/cdn-cgi/image/width=640,f=auto/https://860818f9.website-7p8.pages.dev/_app/immutable/assets/bg.90a72a2b.jpg▾

    Any idea why it is broken and how to fix it?
    v
    s
    • 3
    • 3
  • In the cloudflare page, using langchain to build failed
    d

    dark、

    05/05/2023, 9:13 AM
    I created a SvelteKit project and import Langchain and adapter-cloudflare. When building, an error occurred that said, 'ERROR: No loader is configured for ".wasm" files: ...@dqbd/tiktoken/tiktoken_bg.wasm.' How to solve it?
  • Next JS page reload throwing 404 error when using with pages
    r

    redux1997

    05/05/2023, 1:35 PM
    I am following this guide https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/ to deploy nextjs on pages but rewrites , redirects and middleware not working but it is working if I deploy on vercel .Also when I am reloding page it is throwing 404 error
    b
    • 2
    • 6
  • Can not copy file from source path to target path on R2 using PHP AWS SDK
    t

    thangnm

    05/05/2023, 4:01 PM
    As the title of the post, I’m using the PHP AWS SDK package to connect to CF R2. The connection is successful, and I’ve tried uploading and deleting a file, which both worked fine. However, when I try to copy a file from one location to another on R2, it doesn’t work. There are no errors or logs available. What could be causing this issue, and if someone has experienced this before, could you please guide me on how to resolve it? Thank you very much.
    s
    l
    • 3
    • 9
  • Debugging Remix server-side 500s
    h

    happenator

    05/06/2023, 12:19 AM
    After pushing a change to a Remix app to Pages + Functions, I'm getting
    500
    errors in the browser, but Cloudflare Pages Functions logs show "successful" requests. How do I get the underlying error?
    Copy code
    {
      "outcome": "ok",
      "scriptName": "pages-worker--1051688-production",
      "exceptions": [],
      "logs": [
        {
          "message": [
            "Error: Unexpected Server Error"
          ],
          "level": "error",
          "timestamp": 1683332030573
        }
      ],
      "eventTimestamp": 1683332030459,
      "event": {
        "request": {
          "url": "https://dd33ea81.cf-remix-65c.pages.dev/",
          "method": "GET",
          "headers": {
            ...
          },
          "cf": {
            ...
          }
        },
        "response": {
          "status": 500
        }
      },
      "id": 0
    }
    • 1
    • 1
  • Error: Pages only supports files up to 26.2 MB in size <REACT APP>
    a

    albe

    05/06/2023, 3:05 AM
    D. id: 890f0335-49d2-488c-807c-daaf82443d24 account. id: fde13d91dce361f5bbc45117c97532b7 I am trying to deploy a react app on cloudflare pages but i get this error: Error: Pages only supports files up to 26.2 MB in size can someone help me?
    d
    • 2
    • 5
12345...9Latest