Turnstile protected form on an Astro website hosted on Pages, TS backend on Functions

Hello, I'm building an Astro test site and I would like to have everything "running" on Cloudflare. One of the things I want to demo is a simple form protected by Turnstile. I have no issue with the front-end code which is working fine. When I click on "submit" I'm calling xxx/api/submit, on my project I have a TS script in root/functions/api/submit.ts. I have no error when I'm comitting my code, the functions folder is detected by Pages, but while I'm doing my test and clicking on "submit" on my form I always have a 405 error. I noticed in pages/functions real-time log that I have a double '/' in the path ... that could explain the 405, but on the browser side I don't have the double '/' (see screenshot attached) Any help or ideas will be helpful ! Thanks !
No description
No description
4 Replies
RavenLame
RavenLameOP3w ago
I also noticed that I configured a custom domain for my test site, I'm browsing a URL like : "testwebsite.example.com/api/submit" but on Real-Time logs I can see the default Pages URL like "testwebsite.pages.dev//api/submit"
RavenLame
RavenLameOP3w ago
Yes it is configured ! My bad, it was configured, but with a typo ... now it is working perfectly, URL in my browser is the same than in the logs, api endpoint is answering what I'm expecting
Dj
Dj3w ago
Good morning, glad you got it figured out. You can tag the thread "solved"!

Did you find this page helpful?