• 0 Posts
  • 3 Comments
Joined 2 years ago
cake
Cake day: July 1st, 2023

help-circle


  • data0toWeb DevelopmentCORS error while making request to lemmy API
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    2 years ago

    The Access-Control-Allow-Origin is meant to be set on the server side and is part of a mechanism called CORS. MDN has a good guide on CORS (It might seem too long and complex to read if you just want to access some data on an API, but knowing how it works is essential if you plan to work with HTTP-based APIs.)

    In short, lemmy.ml (and probably most other Lemmy instances) doesn’t seem to allow API access from within a browser. You’ll have to build a Node.js proxy (with lemmy-js-client) and use that to connect the browser to.