I have an AstroJS project here is my astro.config.mjs
:
import tailwind from "@astrojs/tailwind";
import vue from '@astrojs/vue';
import sanity from "@sanity/astro";
import { defineConfig } from 'astro/config';
import { sanityClientConfigWithCdn } from './const';
import node from '@astrojs/node';
export default defineConfig({
output: 'hybrid',
adapter: node({
mode: 'standalone',
}),
integrations: [
tailwind(),
sanity(sanityClientConfigWithCdn),
vue({appEntrypoint: "/src/vue.ts"}),
]
});
Here is my test API endpoint:
import type { APIRoute } from "astro";
export const prerender = false;
export const GET: APIRoute = async ({ params, request }) => {
return new Response(JSON.stringify({
message: "TEST"
}))
}
And finally here my pages file structure:
├── api
│ └── test.ts
└── [...lang]
├── index.astro
└── news.astro
I am getting this error/warning:
06:49:15 PM [getStaticPaths] A `getStaticPaths()` route pattern was matched, but no matching static path was found for requested path `/404`.
Possible dynamic routes being matched: src/pages/[...lang]/index.astro.
06:49:15 PM [serve] 404 /404
At first I was thinking that the [...lang]
dynamic route was the problem. However, I am still getting 404 even after deleting the whole directory. I am executing npm run dev
and trying to access http://localhost:3000/api/test (that is the correct host and port). What could be the problem here?
Turns out I indeed had to upgrade my AstroJS version. A side-effect of using an outdated AstroJS version was that I was installing an outdated of @astrojs/node
so probably this was causing a problem, as well. So same file structure, same code, same everything except from the Astro version and it now works as expected.