Basic API's doesn't work with Vercel :(

Hi there,

I try to work with Astro front-end, and i’ve juste installed minimum required (astro, npm, vercel) on Windows and put a test.js in ./src/pages/api/test.js like :

export async function POST() {
return new Response(JSON.stringify({ message: ‘ok’ }), {
headers: { ‘Content-Type’: ‘application/json’ },
status: 200,
});
}

In localhost that’s ok, BUT : after deployment, when i go to my webstite http://------.app/api/test, i get 404 error : not found.

Could anyone tell me please how to put a basic API (serverless or not, i’ve got the default config with astro) in Vercel ?

astro.config.mjs (standard) :

“”"
import { defineConfig } from ‘astro/config’;
import vercel from ‘@astrojs/vercel’;

export default defineConfig({
adapter: vercel(), //
site: ‘https://xxxxxxx.app’,
});
“”"

And i’ve also noticed that with Sanity studio, sanity hook is not triggering full rebuild when for example creating a new page in sanity, which creates also 404 error because on Vercel we see “prebuilt”, but not true build.

I’m searching for days… thanks for any help ! :frowning:

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.

This has definitely not resolved my problem explained… is there any solution…? :frowning:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.