http-functions return 404

Hi,

My website is alexandruraduca.wixsite.com/popacademy

I’ve created a backend function to query collections by name and no matter what code I write I always get a 404.
Any idea what could be wrong?

Here is my code:

// sample queries:
// https://alexandruraduca.wixsite.com/popacademy/_functions/api/Cursuri
// https://alexandruraduca.wixsite.com/popacademy/_functions/api/Echipa
// https://alexandruraduca.wixsite.com/popacademy/_functions/api/Colectie
import { ok, notFound, serverError } from ‘wix-http-functions’;
import wixData from ‘wix-data’;
export function get_api(request) {
let response = {
“headers”: {
“Content-Type”: “application/json”
}
};
console.log("request received: ",request);
let collection = request.path[0]
// let query = request;
// query a collection to find matching items
return wixData.query(collection)
.find()
.then((results) => {
// matching items were found
if (results.items.length > 0) {
response.body = results.items;
return ok(response);
}
// no matching items found
response.body = {
“error”: “no items found”,
// “query”: query
};
return notFound(response);
})
// something went wrong
. catch ((error) => {
response.body = {
“error”: error,
// “query”: query
};
return serverError(response);
});
}


I even tried with this dummy code and I still get a 404

import {ok, notFound, serverError} from ‘wix-http-functions’;
export function get_testApi(request) {

let response = {
“headers”: {
“Content-Type”: “application/json”
}
};

response.body = {‘items’: [1,2,3]};

return ok(response);
}

I’m having the exact same issue, have you managed to resolve it?

I’m having the exact same issue, have you managed to resolve it?

I have this same issue. I doubt this is a security issue since these http-functions were designed for anonymous site visitors by default. As a temporary workaround for me, I tried using a “use” prefix (instead of “get” prefix) to capture ANY requests to my sample dummy function.

About ‘use()’
All GET, POST, PUT, DELETE, and OPTIONS HTTP requests with an API’s URL will be routed to this function unless another function is defined specifically for the request’s HTTP method