Not able to post data to advancedio function api from browser , showing CORS issue

Not able to post data to advancedio function api from browser , showing CORS issue

  1. const express = require('express');
    const catalyst = require('zcatalyst-sdk-node');
    const cors = require('cors');
    const app = express();
    app.use(cors({
    origin:"*",
    credentials:true
    }));
    app.use(express.json());


    app.post("/test", (req,res) => {
    const catalystApp = catalyst.initialize(req);
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header('Access-Control-Allow-Headers', 'Content-Type');

    const body=req.body;
    const param=req.query;
    console.log(body);
    console.log(param);

    res.status(200).send(JSON.stringify({"req.body": req.body,"message":"test","req.query":req.query,"req":req.method}));
    });

    module.exports = app;
this is the code used in the advancedio function, which is basically returning the passed post data to just test if post data is being received in request.

I am testing this api from a local html file shown below
  1. <script>
    url = "< my-function-url >"; // consider this as my advance function function url
    const payload = {
    "name": "test",
    "phone":"9999",
    "email":"test@test.com"
    };
    console.log('sending',payload);
    fetch(url + '/test?a=abc', {
    method: 'POST',
    headers: new Headers({
    "Accept": "application/json",
    "Content-Type": "application/json"
    }),
    body: payload
    })
    .then(response => response.json())
    .then(data => {
    console.log('Success:', data);
    })
    .catch((error) => {
    console.log('Error:', error);
    });
    </script>

and after running this  js code in browser to call the function-url-api, 
this is the error I am receiving
 

it says
Access to fetch at '{{my-function-url}}' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
test.html:57          POST {{my-function-url}}  net::ERR_FAILED
Error: TypeError: Failed to fetch at test.html:57:3


Need help with the server or client code, what needs to be changed or is there any other setting in catalyst from where we need to enable the CORS, 

The notable thing is : if header is not passed, then the api works but POST data is not received at server. and receive the body as blank
ie
if header's content-type is commented

then the api is executed but the POST Data ie req body is not received at server, the output received in browser console is this.


Any help / Guidance would be greatly appreciated.
Jayesh Sonawane
    • Announcements

    • [Webinar] Deploy Docker apps with AppSail's custom runtime | Feb. 19

      Hi everyone, Join us on February 19, 2026 at 8–9 PM IST for a live Catalyst webinar demonstrating how to deploy OCI-compliant Docker images with AppSail's custom runtime. You’ll learn how to: Package your apps as Docker containers Deploy via CLI or connect
    • Catalyst backs Vite.js!

      Hi everyone, We're happy to support the open-source ecosystem that powers modern web development! If you’re building apps with Vite, Catalyst Slate is your go-to platform to deploy blazing-fast frontend apps with ease, scalability, and zero infrastructure
    • Catalyst QuickML 2025 Year In Review

      Hello everyone 👋 It’s been an exciting year for Catalyst QuickML. In 2025, as the Catalyst platform continued to expand its capabilities, QuickML focused on strengthening reliability, developer control, and operational readiness across the AI lifecycle.
    • Introducing GenAI Features in Catalyst QuickML

      Hi everyone, Building machine learning models can often feel slow and complex, especially when teams wait for perfect certainty before testing their ideas. But in reality, faster progress comes from early experimentation—trying out models quickly, learning
    • Announcing Deprecation of Catalyst File Store, Event Listeners, and Cron

      We would like to announce that the following Catalyst features are now in their deprecation phase and will reach End Of Life (EOL) on 30 April, 2026- Catalyst File Store Catalyst Event Listeners Catalyst Cron New users who sign up for Catalyst from today

      Catalyst Community