C
C#•3y ago
Heartbeat1

.net core Razor callback from Discord behind reverse Proxy

Hey Everyone, i am not sure if you can help me here. I Build an Razor Pages application which works fine on my PC, the Callback from oauth Discord worrks fine. Now i am trying to Publish it on an IIS behhind an Reverse Proxy. The Site at it self works fine, but the Discord Login didnt work. The Server is running under 192.168.2.20 and the reverse Proxy is rewriting the Url and Headers. Right now when i am at the Point with the url callback from Discord i getting an error. I tried to publish with debug settings butt he Error Page is the same. Does someone have an idea or an tipp how can i enable the Development mode on iis? Thanks
24 Replies
undisputed world champions
it says so in the error message: set the environment variable "ASPNETCORE_ENVIRONMENT" to Development an other thing you might want to consider is getting your logging setup. this will benefit you in the long run, too (when other errors happen) 😉
Heartbeat1
Heartbeat1OP•3y ago
yeah but whhere can i set the variables? 😉 What do you mean with the logging setup?
undisputed world champions
Environment Variables
Overview The element of the / element specifies a list of environment variables that Intern...
undisputed world champions
if you setup logging, you can check the logs to see what error occurred, instead of having to enable development mode, to see the error when you call the webpage
Heartbeat1
Heartbeat1OP•3y ago
oaky thanks, i will check the logging maybe i need to edit the logging 😉 @icebear i am not sure if it could be that this is the problem Log: GET /auth/oauthCallback code=cBcS Browser: /auth/oauthCallback?code= in the log file the ? is missing
Heartbeat1
Heartbeat1OP•3y ago
okay i found the settings, now i need to check hats wrong here...
undisputed world champions
that looks like the iis request log i think that's the normal format for it (without the "?") i was mostly talking about logging within your app (with "Microsoft.Extensions.Logging" for example) not sure about the error tbh ... maybe check samesite settings catshrug
Vito
Vito•3y ago
Do you get 502 error on post? @Heartbeat
Heartbeat1
Heartbeat1OP•3y ago
no its an 500. I think its the case of rewriting thhe urrl
Heartbeat1
Heartbeat1OP•3y ago
i am not sure if i can change the callback URL, but also trying to change the internal to https.
Heartbeat1
Heartbeat1OP•3y ago
in the package i have only the possibilities to set the callback string
Vito
Vito•3y ago
Aha okay I was just wondering because just yesterday I had similar problem where in development it was working fine but after putting it in production behind nginx reverse proxy I was getting same error and it ended up being problem that header was too big beacuse of auth cookies Yes for sure you need to use https Did you forward protocol from header?
Vito
Vito•3y ago
Configure ASP.NET Core to work with proxy servers and load balancers
Learn about configuration for apps hosted behind proxy servers and load balancers, which often obscure important request information.
Vito
Vito•3y ago
Beacaue in reverse proxy if you have ssl offloading
Heartbeat1
Heartbeat1OP•3y ago
yeah forwarded everything, i am not sure if i can get it wworking internally with https 😉
Vito
Vito•3y ago
You have to do this
Heartbeat1
Heartbeat1OP•3y ago
okay i will check the link app.Use((context, next) => { context.Request.Scheme = "https"; return next(context); }); i thinkk this will help me
Vito
Vito•3y ago
One way to do it, not best way but for testing purposes
Heartbeat1
Heartbeat1OP•3y ago
yeah need to check and then try to rebuild it internally to https. Not sure if i can get it worrking .... 😉
Vito
Vito•3y ago
Vito
Vito•3y ago
I use this for header forwarding
Heartbeat1
Heartbeat1OP•3y ago
okay thanks
Vito
Vito•3y ago
Np, hope i can help
Heartbeat1
Heartbeat1OP•3y ago
yeah the setting with context.Request.Scheme = "https"; worrked... 😉 for the moment i thhink i will leave it like that but try to change it to internal hhttps thanks for the hints
Want results from more Discord servers?
Add your server