NodeJS, how do I implement cors functionality

I am currently trying to implement the LinkedIn API into my node website, and I am running into an issue where I get a ‘cors’ error

I have tried using the npm cors library, such as:

app.use(cors());
app.options('*', cors())

Though nothing is working, I just keep getting the error ‘CORS Missing Allow Origin’. I have tried everything, used Google, asked friends. I have no idea what I am doing wrong?

This is how I am fetching stuff (everything is on http://localhost:3000):

// runs this script after LinkedIn API redirects back to my site.
<script>
    window.onload = function() {
        const queryString = window.location.search
        const urlParams = new URLSearchParams(queryString)
        const page_type = urlParams.get("code")
        console.log('queryString: ' + queryString)
        console.log('urlParams: ' + urlParams)
        console.log('page_type: ' + page_type)
        try {
            const res = fetch('https://www.linkedin.com/oauth/v2/accessToken?client_id=869xpruolc8wci&client_secret=REDACTED&grant_type=authorization_code&redirect_uri=http://localhost:3000/auth/linkedin/callback&code='+page_type, {
                method: 'POST',
                host: 'www.linkedin.com',
                headers: {'Content-Type': 'x-www-form-urlencoded'}
            })
            console.log('success!')
        } catch (err) {
            console.log(err)
        }
    }
</script>

CORS is something you have to implement on the server-side. In your case, LinkedIn has to do that or respectively allow requests from your domain and then they will a CORS response header your browser is reading.
If this response header is missing, your browser will block the response.

You aren’t using the official api!
If I google ‘linkedin api’ the very first result is this Developers | LinkedIn
Where you even get greeted with multiple links to guides on how to get an access token. They even include samples.

Start reading the docs.