Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPTIONS requests sent only #73

Open
jorr opened this issue Apr 10, 2019 · 1 comment
Open

OPTIONS requests sent only #73

jorr opened this issue Apr 10, 2019 · 1 comment

Comments

@jorr
Copy link

jorr commented Apr 10, 2019

Hi there,

I can't seem to make JSNLog work and maybe I'm missing something obvious.
I have an Angular 5 front-end and a separate API server backend in Django.
I have basically followed the instructions here: http://jsnlog.com/Documentation/HowTo/Angular2Logging
and used JL.setOptions with defaultAjaxUrl pointing to my django API endpoint. I just wanted to check what's being sent.

I then throw an error somewhere on my UI interactions to see whats going on.
But all that happens is my endpoint being hit with an endless stream of OPTIONS xhr requests. No POST is ever sent and the OPTIONS are unceasing either.

What am I doing wrong?

@crumhorn
Copy link

crumhorn commented Sep 13, 2019

Late reply I guess, but if your URL is on a different server, Chrome will do a pre-flight Options request prior to letting the POST go. You need to respond to it. If you want any cross-domain Options request to pass, just add these headers to the options response on the server side:

response.addHeader("Access-Control-Allow-Origin", "*")
response.addHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Methods, Access-Control-Allow-Credentials, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, authorization, remoteServer, service, section, username, password, X-QueryName, X-Crud, X-Section, jsnlog-requestid"); 

And the request should pass. You'd do this in whatever the end point handler is on the server. in Java you'd override the doOptions() method on a HttpServlet for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants