Closed Matojeje closed 2 years ago
Thanks!
Also, would it be possible to use something like wildcards for this?
I will look into the possibility of using wildcards, but I'm wary of allowing all possible subdomains because some of them serve user-created content (i.e. cdn.discordapp.com
).
Speaking off, it might be good to add the additional subdomains for both discord.com
and discordapp.com
, since the reason I added discordapp.com
in the first place was because someone's Discord was still connecting to it instead of the new domain.
I will investigate and make the changes in your branch before I merge it.
Looks good, I'll just reformat the list of domains since it's quite a lot of them at this point and the line of code is getting long.
Side note: If you have the time and interest, please post more information about the errors when you tried to build the project. I want to make sure it's as easy as possible for people to fork and build the project, so I'd like to know if the error is something I can fix on my end or write documentation for.
tl;dr Non-stable releases of Discord throw a hissy fit about CORS with the DHT internal server. It's because the app's (sub)domain is different - like
https://canary.discord.com
, and that's not included in this one file, so I modified it.The problem
I kept getting the following console errors (on Desktop/Chromium and Firefox respectively) whenever I pressed Start Tracking:
So I looked into the tracking script, but none of my attempts to fix it worked. After a bit more research, it turns out the problem is on the server side.
The fix
I'm not very experienced with C#, so I referred to this) to make sure that
WithOrigins()
's parameters are just an array. I hope that's right.Unfortunately I wasn't able to test out my code changes, since I kept running into problems with packages despite having the right version of the SDK, even trying to install them manually didn't work, but I'm sure that's just a skill issue on my part.
The only error code I kept getting was
NU1100
, sayingUnable to resolve
followed by whatever's included in each.csproj
file as a<PackageReference>
.I didn't have time to look into this further to try and fix my dependencies, because I had to back up a server that was about to get deleted on a short notice. So I ran the tracker in this way instead:
The workaround
The current workaround for this CORS conundrum - without changing anything in DHT's code - is simply using the stable Discord web app or desktop client for running the tracking script. I went ahead and tested different release channels to see where the CORS stuff is okay:
So it's clear that the problem was just the domain of the Discord app, and I'm pretty sure this will fix it.
(I haven't tested if the CORS error occurs in the development version of desktop Discord because I had no clue that was even a thing until today.)
Also, would it be possible to use something like wildcards for this? (such as
https://*.discord.com
) I'm not sure if the ASP.NET builder stuff supports it, but it might be possible by just writing the response headers manually.