#Server actions not callable from pre-rendered pages

1 messages · Page 1 of 1 (latest)

atomic frigate
#
<script>
    import { actions } from "astro:actions";

    const button = document.getElementById("increment");
    button?.addEventListener("click", async () => {
        const { data, error } = await actions.addStar();
        console.log(data, error);
    });
</script>

Gives

$ astro dev
09:27:24 [@astrojs/cloudflare] Enabling image processing with Cloudflare Images for production with the "IMAGES" Images binding.
09:27:24 [@astrojs/cloudflare] Enabling sessions with Cloudflare KV with the "SESSION" KV binding.
09:27:24 [ERROR] [astro:actions] An unhandled error occurred while running the "astro:routes:resolved" hook
[ActionsWithoutServerOutputError] A server is required to create callable backend functions. To deploy routes to a server, add an adapter to your Astro config and configure your route for on-demand rendering
  Hint:
    Add an adapter and enable on-demand rendering: https://docs.astro.build/en/guides/on-demand-rendering/
  Error reference:
    https://docs.astro.build/en/reference/errors/actions-without-server-output-error/
 ELIFECYCLE  Command failed with exit code 1.
#

Okay it does work, as soon as I have at least one page with export const prerender = false;

#

But all the pages I have are export const prerender = true; I get the warning. So looks like the check is not taking that into account.

plush trellis
#

Ah I was about to say "I wonder if it's a bug where actions aren't detected to enable the server bundle without at least one server for"

#

We had that before for server islands.

atomic frigate
#

I do have an adapter and output: "server" though in astro.config.ts

#

So in my understanding, I do force server mode already 🤔

plush trellis
#

Yeah that would be my expectation too. I'd create an issue with the repro.

#

Might also be worth double checking with a different adapter to see if it's CF or any adapter that has this issue.