Netlify Function Callback

I’m trying to figure out how netlify function callback works. Since the deploy api returns a CORS error if called from the frontend (browser), i decided to use Netlify functions. The site is created successfully, here’s my code:

fetch('https://api.netlify.com/api/v1/sites', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/zip',
            Authorization: 'Bearer ' + 'Auth'
        },
        data: 'myfile.zip',
    })

However, I’m getting an empty response, instead of the site id and other values.

Please let me know if you need more information

You’re using the endpoint to create a site. To deploy the site, you’d need: Get started with the Netlify API | Netlify Docs

Note that, serverless functions can accept a maximum payload of 6 MB, so sites bigger than that won’t upload.

You can create and deploy the website if you add a zip file to the request. Even when the deploy fails, the site will still be created and the request should return a site id.

However, since I couldn’t figure why the function isn’t returning anything, I’m using a Node proxy and it works well.