“Masalah CORS Angular” Kode Jawaban

Cara Memperbaiki Cors dalam Angular

in PHP server:
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
    header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, X-Auth-Token, content-type');

in Angular POST request:
	const httpOptions = {
 	 	headers: new HttpHeaders()
	}

    httpOptions.headers.append('Access-Control-Allow-Origin', '*');
    httpOptions.headers.append('Content-Type', 'application/json');
    httpOptions.headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

	this.httpClient.post(<url>, <body>, httpOptions);
Nickton

Masalah CORS Angular

header('Access-Control-Allow-Origin: *');
Ashamed Ant

Menambahkan COR dalam sudut

"architect": {
    "serve": {
            "builder": "@angular-devkit/build-angular:dev-server",
            "options": {
                "browserTarget": "project-name:build",
                "proxyConfig": "src/proxy.conf.json"
            },
          }
}
Quaint Quail

Jawaban yang mirip dengan “Masalah CORS Angular”

Pertanyaan yang mirip dengan “Masalah CORS Angular”

Lebih banyak jawaban terkait untuk “Masalah CORS Angular” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya