Hi guys, I was trying to learn how to use serverless functions. It is working in “netlify dev”, but no matter what I tried the serverless function is not found when deployed.
This is the link to my demo website: https://test-serverless-function-aaassww.netlify.app/. The website is built with Qwik framework with the initial setup.
This is how I write the function in netlify/functions/hello-world.mjs:
export default async () => {
return new Response(‘<p>Hello world</p>’, {
status: 200,
headers: { ‘Content-Type’: ‘text/html’ }
})
}
export const config = {
path: “/hello-world”,
}
In the “netlify dev” mode when I go to “http://localhost:8888/hello-world”, it is working.
After the website is built and deploy, I can find the function on the dashboard
But when I try to access the function on production, “https://test-serverless-function-aaassww.netlify.app/hello-world”, I was getting 404 error, stating resource not found.
I also tried “https://test-serverless-function-aaassww.netlify.app/.netlify/functions/hello-world”, but it was not working too.
I have created a Github repo for this: https://github.com/HaoZhenSiow/test-serverless-function
Please help a bro out, thanks in advance.