Getting 401 error when implementing Authorization Code Flow in Sveltekit app using axios, but fine in CURL

Hi there:

We’re using svelte/sveltekit for a new “Regular Web” application, and we’re testing implementation of the basic Authorization Code Flow as recommended by auth0. After the user logs in, and we receive the authorization code, we redirect them back to our callback endpoint. where our server tries to exchange the code for a token.

export async function get(req) {
    const code = req.url.searchParams.get("code");
    const accessToken = await getAccessToken(code);
    return {
        body: JSON.stringify(accessToken)

The getAccessToken function looks as follows:

function getAccessToken(code: string) {
 return<{ accessToken: any }>(
            client_id: config.auth0.clientId,
            client_secret: AUTH0_CLIENT_SECRET,
            code: code,
            grant_type: "authorization_code",
            redirect_uri: "http://localhost:3000"
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
    ).then(response => {
    }).catch(error => {

This request returns a 401 error (access denied). The same request with the same parameters in using curl succeeds.