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 :: quiz javascript 
Javascript :: assertion error in jest 
Javascript :: js remove entry 
Javascript :: switch statement 
Javascript :: hamburger menu js 
Javascript :: cross browser testing 
Javascript :: how to sort string alphabetically in javascript 
Javascript :: get the last element of array javascript 
Javascript :: add to json object javascript 
Javascript :: make button disabled if input is empty angular 
Javascript :: useeffect react 
Javascript :: javascript map mdn 
Javascript :: how to wait for function to finish in JS 
Javascript :: npm ERR! missing script: build:dev 
Javascript :: react native update helper 
Javascript :: axios async await 
Javascript :: number , number methods in js 
Javascript :: use of slot in vue 
Javascript :: use ref in component reactjs 
Javascript :: node red push to array 
Javascript :: pass obj to vuex action 
Javascript :: une expression de fonction en javascript 
Javascript :: binding variable with td in angular site:stackoverflow.com 
Javascript :: string .length js 
Javascript :: for (var i = 0; i < 10; i++) { setTimeout(function () { console.log(i) }, 10) } What 
Javascript :: input type disappear side scroll react 
Javascript :: onclick confirm jquery anchor tag 
Javascript :: moment get end of next moenth 
Javascript :: eosio name to int js 
Javascript :: node.js wikipedia api call 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =