Answer the question
In order to leave comments, you need to log in
How to CORS POST them to Angular2 with application/json mime type?
From Angular I make a POST like this:
export class AuthenticationService {
public token: string;
private headers = new Headers({'Content-Type': 'application/json'});
...
login(email: string, password: string): Observable<boolean> {
return this.http
.post("http://localhost:3500/login", JSON.stringify({ email: email, password: password }), this.headers)
...
Answer the question
In order to leave comments, you need to log in
the frontend does everything right for you
options the browser itself sends
kill your server and look at nc -lp 3500
the backend should answer with the headers that all the rules
https://developer.mozilla.org/en-US/docs/Web/HTTP/...
your last parameter is wrong
post("http://localhost:3500/login", JSON.stringify({ email: email, password: password }), {headers: this.headers})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question