Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to fix cors in 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);
Comment

angular cors issue

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

adding cors in angular

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

PREVIOUS NEXT
Code Example
Javascript :: js data object length 
Javascript :: jquery select dropdown option 
Javascript :: $lookup in mongodb 
Javascript :: datatable get row data 
Javascript :: number format currency 
Javascript :: hex to rgb function 
Javascript :: add query parameter to url react router v6 
Javascript :: how to pass data between components in react 
Javascript :: nodejs buffer.from base64 
Javascript :: npm verbose stack error 
Javascript :: deserialize json jquery 
Javascript :: js split array into smaller arrays 
Javascript :: bootstrap time picker 12 hour format 
Javascript :: dart code formatter vscode 
Javascript :: convert string to set in js 
Javascript :: how to show modal with jquery 
Javascript :: action checkbox selected vue js 
Javascript :: javascript example of foreach loop 
Javascript :: unique element in array 
Javascript :: express get remote ip 
Javascript :: angular ngmodel checkbox 
Javascript :: check css property jquery 
Javascript :: fonction fleche javascript 
Javascript :: convert 24 hour to 12 hour moment js 
Javascript :: how to make a game in unity with javascript 
Javascript :: instantiate template playcanvas 
Javascript :: js array backwards 
Javascript :: jquery element width 
Javascript :: continuos scrollling js 
Javascript :: javascript anagram 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =