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

    upinthisjoynt

    01/13/2023, 12:19 AM
    HI All... I'm trying to "fetch" my function, but I keep getting a 404. I'm able to fetch it locally (localhost:xxx/api/sendinfo), but when I build it in pages, I use "/api/sendinfo" for the fetch url and I get a 404. What am I doing wrong? Do I need to do something special to publish the functions folder? is the url correct? *losing my mind. lol
  • w

    Walshy | Pages

    01/13/2023, 12:21 AM
    Is the
    functions
    dir at the root of your project?
  • u

    upinthisjoynt

    01/13/2023, 12:22 AM
    It's inside of the "pages" folder where the src. in stuff is... pages >functions pages>src>routes
  • u

    upinthisjoynt

    01/13/2023, 12:23 AM
    Not sure if that's the right location
  • w

    Walshy | Pages

    01/13/2023, 12:23 AM
    In the Pages dash, what's your Root Directory set to?
  • w

    Walshy | Pages

    01/13/2023, 12:23 AM
    is it set to
    pages
    ?
  • u

    upinthisjoynt

    01/13/2023, 12:23 AM
    please forgive me... what is "Pages dash"?
  • w

    Walshy | Pages

    01/13/2023, 12:24 AM
    https://dash.cloudflare.com?to=/:account/pages/view/:pages-project/settings/builds-deployments Cloudflare dashboard, in the Pages section 🙂
  • u

    upinthisjoynt

    01/13/2023, 12:26 AM
    oh! HA! it shows: gitlab: user.name/pagesRoot pages-root.pages.dev
  • u

    upinthisjoynt

    01/13/2023, 12:26 AM
    I hope that helps
  • w

    Walshy | Pages

    01/13/2023, 12:29 AM
    https://i.walshy.dev/1673569774.png#b06156f309c221ca13b50e30a77329182bfc50a6598aacfcd2ca53ed9c4474ab
  • w

    Walshy | Pages

    01/13/2023, 12:29 AM
    Do you see this "Builds & deployments" in "Settings"?
  • w

    Walshy | Pages

    01/13/2023, 12:30 AM
    yeah? Go into it and look for this section: https://i.walshy.dev/1673569826.png#1dec48d20b56a9a1b3366c64c0996d035fabfc46df5efd8c33b2248a09f32ae5
  • w

    Walshy | Pages

    01/13/2023, 12:30 AM
    What's the "Root directory:" set to?
  • u

    upinthisjoynt

    01/13/2023, 12:31 AM
  • w

    Walshy | Pages

    01/13/2023, 12:31 AM
    Ah ha there it is!
  • w

    Walshy | Pages

    01/13/2023, 12:32 AM
    Set that to
    pages
    and it should be good 🙂
  • u

    upinthisjoynt

    01/13/2023, 12:33 AM
    going to try it! Thank you soooo much!
  • u

    upinthisjoynt

    01/13/2023, 12:41 AM
    Ok... no love. It wouldn't build. I does build with the path being empty. Here's my directory structure
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:42 AM
    Aha, you're using Sveltekit
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:42 AM
    So by default Sveltekit overrides all Functions with their own SSR adapter meaning no Functions will be deployed, only their Server Routes
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:42 AM
    What you need to do is to switch to their format.
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:43 AM
    See Server Routes with Sveltekit, keeping in mind the path (it's inside src/routes like regular pages)
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:43 AM
    https://kit.svelte.dev/docs/routing#server
  • u

    upinthisjoynt

    01/13/2023, 12:44 AM
    Checking
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:45 AM
    You'll also need to have the root directory set
  • i

    Isaac McFadyen | YYZ01

    01/13/2023, 12:45 AM
    (because it's in a subpath of your repo, in /pages)
  • u

    upinthisjoynt

    01/13/2023, 1:08 AM
    I think I got it. We should really document that nuance somewhere. Thank you so much
  • u

    upinthisjoynt

    01/13/2023, 1:08 AM
    You were a GREAT HELP! Thank you!!
  • c

    Crazy Rabbit

    01/13/2023, 6:57 AM
    Also how is pulling data from KV, faster than normal Cloudflare Page?
1...332333334...392Latest