5
submitted 1 year ago by diamond@beehaw.org to c/support@beehaw.org

Hey Beehaw mods!

I'm currently working on a Lemmy web client, but the lack of proper CORS headers is preventing anything from working :(

I just wanted to ask if the appropriate CORS headers could be added to the front-facing proxy layer. If you're using Caddy, I believe something like this should do the trick:

reverse_proxy ... {
  header_down Access-Control-Allow-Origin *
  header_down Access-Control-Allow-Methods *
  header_down Access-Control-Allow-Headers *
}

Relevant issue: https://github.com/LemmyNet/lemmy/issues/3109

you are viewing a single comment's thread
view the rest of the comments
[-] diamond@beehaw.org 2 points 1 year ago

The websocket needs the right URL or it won’t work, you can’t always assume the websocket endpoint is at the root of the domain.

Right. I was reading a code snippet from somewhere else where they called into the root path, but the library that they were using probably did the appending in the background which I didn't know.

That’s annoying, though, because setting up the right CORS headers to allow arbitrary online clients is a pain and I suspect many instance admins won’t do it.

There is an issue upstream tracking this. For now, I only mostly use Beehaw, so that's fine.

As a side note, are you implementing the API from scratch? Because there’s a Javascript (Typescript) API that gets auto generated from the Lemmy sources that’s ready to use (supports both REST and WS).

Nope, I'm using lemmy-js-client. The WS part of it doesn't do much, so I didn't bother using it. The LemmyWebsocket type wasn't also in the main import for some reason, but that wasn't much of an issue.

this post was submitted on 17 Jun 2023
5 points (100.0% liked)

Beehaw Support

2797 readers
1 users here now

Support and meta community for Beehaw. Ask your questions about the community, technical issues, and other such things here.

A brief FAQ for lurkers and new users can be found here.

Our September 2024 financial update is here.

For a refresher on our philosophy, see also What is Beehaw?, The spirit of the rules, and Beehaw is a Community


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.


if you can see this, it's up  

founded 2 years ago
MODERATORS