我有一个AstroJS项目,这是我的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"}),
]
});
下面是我的测试API终结点:
import type { APIRoute } from "astro";
export const prerender = false;
export const GET: APIRoute = async ({ params, request }) => {
return new Response(JSON.stringify({
message: "TEST"
}))
}
最后是我的页面文件 struct :
├── api
│ └── test.ts
└── [...lang]
├── index.astro
└── news.astro
我收到此错误/警告:
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
起初我认为[...lang]
动态路由是问题所在.但是,我仍然得到404即使删除整个目录.我正在执行npm run dev
并try 访问http://localhost:3000/api/test(这是正确的主机和端口).有什么问题吗?