server action without declaring `export const runtime = 'edge';`

is there a way to make the server action be served on a separate URL & not in the page it's used in?
35 Replies
lettucebaran
lettucebaran•4mo ago
@Firu did you manage to solve this issue? If so, how?
Firu
FiruOP•4mo ago
Wow this has been a very long time Nope, I gave up on Server Actions I'm using plain ole Route Handlers or a separate backend
lettucebaran
lettucebaran•4mo ago
At this point, I will have to give up too
Firu
FiruOP•4mo ago
on Cloudflare Workers still yeah, it's a mess the "magic" really ruins the experience
lettucebaran
lettucebaran•4mo ago
btw do you know if I can call an endpoint to make a form without using export const runtime = 'edge';?
Firu
FiruOP•4mo ago
i prefer more control I don't think so the edge runtime is needed for Cloudflare Pages it's in the docs somewhere, check it out like I have to use it for dynamic routes when i read the request which in theory is the same for forms
lettucebaran
lettucebaran•4mo ago
that's a shame, because i have only ~15 pages and i am already at the limit of max. of 10mb
Firu
FiruOP•4mo ago
dang what? 10mb for 15 pages sounds crazy what kind of website is it?
lettucebaran
lettucebaran•4mo ago
and every time i declare export const runtime = 'edge';, then it takes ~0.8mb. So, I am looking for ways to not use export const runtime = 'edge'; it's a CRUD app with auth, that's it really
Firu
FiruOP•4mo ago
Also, just saw the blog post in your bio. Absolutely based, ill read it later hmmmm what's stopping you from making a dedicated route handler and controlling the form with a client component to send to the route handler?
lettucebaran
lettucebaran•4mo ago
I can do that too, Q1. Do I have to declare export const runtime = 'edge' in every route.ts? Q2. Do I have to declare export const runtime = 'edge' in page.tsx when making a request to the endpoint?
Firu
FiruOP•4mo ago
I'm doing i18n on my layout so it's on the edge runtime, and it only takes up 270kb
lettucebaran
lettucebaran•4mo ago
are you using nextjs and next-on-pages?
Firu
FiruOP•4mo ago
1. yeah, here are the relevant docs https://developers.cloudflare.com/pages/framework-guides/nextjs/deploy-a-nextjs-site/#edge-runtime 2. Depends how you're making the request. The only time I used the edge runtime for any of my pages is when they're dynamic and need to access the request
Cloudflare Docs
Full-stack deployment · Cloudflare Pages docs
Deploy a full-stack Next.js site (recommended).
Firu
FiruOP•4mo ago
like for i18n routing yup! the edge runtime thing is the limitation im facing with i18n because i can't statically generate the pages due to being forced to use the edge runtime on the layout so request usage go up also how the router counts each <Link> navigation as a request so I had to optimize my code to use Client components to lessen the reliance on the request-based routing but other than that, no issues
lettucebaran
lettucebaran•4mo ago
yeah, that makes sense
Firu
FiruOP•4mo ago
but I also don't use Server Actions so take my thoughts with a grain of salt 😜
lettucebaran
lettucebaran•4mo ago
tbf at this point i might get rid of them how do you know its 270kb?
Firu
FiruOP•4mo ago
my build logs say so when I deploy also when you run npm run build iirc
lettucebaran
lettucebaran•4mo ago
do you have auth or have forms? e.g., react-hook-form
Firu
FiruOP•4mo ago
im on mobile atm, so not sure My auth is done on the client with Supabase with RLS so no need for server interaction no forms anyway, let me know if you find a way to optimize your code im curious to see the issue god speed!
lettucebaran
lettucebaran•4mo ago
thanks! @Firu it was Sentry, it added ~1445kb to each edge function. Now, I don't know what I should use instead of Sentry
Firu
FiruOP•4mo ago
OOF, no wonder glad you figured it out TIL
lettucebaran
lettucebaran•4mo ago
thanks!
Firu
FiruOP•3mo ago
Did you manage you figure out an alternative, @lettucebaran? I'm on the same boat at the moment, Cloudflare Pages won't build my site & the bundle sizes ballooned 😂 I tried removing the client config to opt-out of bundling the code with the client, but it doesn't help
lettucebaran
lettucebaran•3mo ago
Nope. My app doesn't have an error tracker 🥲 I was thinking of adding Sentry only in the FE (assuming that won't drastically increase the bundle size)
Firu
FiruOP•3mo ago
Have you tried it?
Firu
FiruOP•3mo ago
Also I found this https://axiom.co/
Axiom
Stop sampling, observe every event – Axiom
100% of your data for every possible need: o11y, security, analytics, and new insights.
Firu
FiruOP•3mo ago
i'll look into it next
lettucebaran
lettucebaran•3mo ago
Nope
Firu
FiruOP•3mo ago
@lettucebaran it's what we're looking for not as feature rich or "handholdy" as Sentry but also not bloated at all
Firu
FiruOP•3mo ago
my bundle sizes are back to normal
No description
Firu
FiruOP•3mo ago
you get to choose what to log so not necessarily just for errors great tech and their free tier is 0.5TB per month with 30d retention
lettucebaran
lettucebaran•3mo ago
Nice, thanks for the update Did you settle on this tool to observe the app?
Firu
FiruOP•3mo ago
Yep Pretty happy with it so far It's my first time implementing o11y in-depth, so I'm not the right person to judge whether it's perfect but it fulfills its immediate utility at the moment as an error & logger for us to drill-down & investigate app errors both server & client
Want results from more Discord servers?
Add your server