#CROS ERROR

20 messages · Page 1 of 1 (latest)

tall scarab
#

i'm working rn on a side project that can show a linked in job posts in the website, i added a NPM pakage :(https://www.npmjs.com/package/linkedin-jobs-api)
and when i tried to use it there is a problem :

Access to XMLHttpRequest at 'https://www.linkedin.com/jobs-guest/jobs/api/seeMoreJobPostings/search?keywords=software+engineer&location=Egypt&f_TPR=r604800&f_SB2=1&f_E=2&f_WT=3&f_JT=F&start=0' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

What should i do in the next config ?

   async rewrites() {
        return [
            {
                source: '/api/:path*',
                destination: 'https://www.linkedin.com/:path*',
            },
        ]
    },
topaz sleetBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

      🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>

      ✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
      (if you don't see the option, try refreshing Discord with Ctrl + R)
tall scarab
pale linden
#

If you fetch from your client, you'll get cors errors. You'd need to fetch from the server.

tall scarab
#

the thing is there is a link to a page that is not JSON file it's a HTML and it has the data that i need

tall scarab
#

@pale linden no it's a normal html

pale linden
#

you can't just request html from a URL, that's what cors protection is for

pale linden
#

oh

tall scarab
#

This is the link that get prented into my consol

pale linden
#

I didn't see the API part 🤔 interesting. But still needs to be fetched from the server, so either getServerSideProps or in a server component in the app directory

tall scarab
#

Aha i guss that i need to try the server side propse since i use a package that not mine

pale linden
#

I'm kinda shocked that linkedin provides an html endpoint 😂 I guess they want people to scrape their site

tall scarab
#

Or maybe creating a custom script that extract the data from the html

tall scarab
#

And its very different

pale linden
#

You could just scrape it with something like puppeteer

#

but that can get kinda expensive unless you're doing it in batch