Aspiring Web Developer here. Question about the API.

Posts: 3 · Views: 386
  • 23637

    I'm trying to use the wallhaven api to generate wallpapers for my web application. I am using a chrome with CORS enabled but when I try to fetch for wallhaven, I get "Access to fetch at 'https://wallhaven.cc/api/v1/search' from origin 'null' has been blocked by CORS policy: 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." I have read online that generally, this error is because the site you are trying to fetch from does not have my/all origin to allow access from my browser. Is this true? Have any of you guys got the API to work running a server with chrome?

  • 24147

    You'll have to use a backend. Like node. They have told me they don't use CORS, so removing any cors options from the request headers will just make things worse.

    You'll have to process it on a backend.

    Create your own api link to your node, then process the wallhaven request and return the results. Better to store the api key on the server and not the client as well.... if you're using an api key

    Last updated

Message