Access to XMLHttpRequest at 'http://localhost:3000/framework/create' from origin 'http://localhost:4200' has...
up vote
0
down vote
favorite
i have an error
Access to XMLHttpRequest at 'http://localhost:3000/framework/create' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how i fix it?
i'm use angular v7 and express.js for backend
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({providedIn : 'root'})
export class CommonService {
uri = 'http://localhost:3000/framework';
constructor(private http: HttpClient) { }
addFramework(framework, bahasa) {
const obj = {
framework: framework,
bahasa: bahasa
};
console.log(obj);
this.http.post(`${this.uri}/create`, obj)
.subscribe(res => console.log('Done'));
}
}
angularjs express
add a comment |
up vote
0
down vote
favorite
i have an error
Access to XMLHttpRequest at 'http://localhost:3000/framework/create' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how i fix it?
i'm use angular v7 and express.js for backend
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({providedIn : 'root'})
export class CommonService {
uri = 'http://localhost:3000/framework';
constructor(private http: HttpClient) { }
addFramework(framework, bahasa) {
const obj = {
framework: framework,
bahasa: bahasa
};
console.log(obj);
this.http.post(`${this.uri}/create`, obj)
.subscribe(res => console.log('Done'));
}
}
angularjs express
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i have an error
Access to XMLHttpRequest at 'http://localhost:3000/framework/create' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how i fix it?
i'm use angular v7 and express.js for backend
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({providedIn : 'root'})
export class CommonService {
uri = 'http://localhost:3000/framework';
constructor(private http: HttpClient) { }
addFramework(framework, bahasa) {
const obj = {
framework: framework,
bahasa: bahasa
};
console.log(obj);
this.http.post(`${this.uri}/create`, obj)
.subscribe(res => console.log('Done'));
}
}
angularjs express
i have an error
Access to XMLHttpRequest at 'http://localhost:3000/framework/create' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how i fix it?
i'm use angular v7 and express.js for backend
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({providedIn : 'root'})
export class CommonService {
uri = 'http://localhost:3000/framework';
constructor(private http: HttpClient) { }
addFramework(framework, bahasa) {
const obj = {
framework: framework,
bahasa: bahasa
};
console.log(obj);
this.http.post(`${this.uri}/create`, obj)
.subscribe(res => console.log('Done'));
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({providedIn : 'root'})
export class CommonService {
uri = 'http://localhost:3000/framework';
constructor(private http: HttpClient) { }
addFramework(framework, bahasa) {
const obj = {
framework: framework,
bahasa: bahasa
};
console.log(obj);
this.http.post(`${this.uri}/create`, obj)
.subscribe(res => console.log('Done'));
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({providedIn : 'root'})
export class CommonService {
uri = 'http://localhost:3000/framework';
constructor(private http: HttpClient) { }
addFramework(framework, bahasa) {
const obj = {
framework: framework,
bahasa: bahasa
};
console.log(obj);
this.http.post(`${this.uri}/create`, obj)
.subscribe(res => console.log('Done'));
}
}
angularjs express
angularjs express
asked Nov 21 at 1:55
rizky alviandra
66
66
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404273%2faccess-to-xmlhttprequest-at-http-localhost3000-framework-create-from-origin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown