79803817

Date: 2025-10-29 12:57:46
Score: 0.5
Natty:
Report link

For me, the answer from @devzom actually worked. After a little research into it I found that by default, Astro uses static site generation (SSG) where pages are pre-rendered at build time. In default ('static') mode, routes with dynamic query parameters don't work properly because there's no server running to handle the requests at runtime.

By adding output: 'server', you're telling Astro to run in Server-Side Rendering (SSR) mode, which means there's an actual server processing requests, so dynamic routes with query parameters work correctly.

In the file astro.config.mjs

export default defineConfig({
    output: 'server',
});

I then put my code up on DigitalOcean and had to install the following adapter:

npm install @astrojs/node

(or in my case, since I was using an older theme: npm install @astrojs/node@^8.3.4 )

Then your astro.config.mjs looks like:

import node from '@astrojs/node';

export default defineConfig({
    output: 'server',
    adapter: node({
        mode: 'standalone',
    }),
});

There are also hosting adapters for Vercel, Netlify, and Cloudflare
https://docs.astro.build/en/guides/on-demand-rendering/

As others have mentioned, setting output to 'hybrid' in astro.config.mjs will work, but you will need to add "export const prerender = false;" at the top of the page that you want to get the query parameters for, basically this is telling the file that the route in that file needs SSR.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @actually
  • Low reputation (1):
Posted by: Mogul