Angular Access-Control-Allow-Origin PHP htaccess

Angular Access-Control-Allow-Origin PHP htaccess

Today, We want to share with you Angular Access-Control-Allow-Origin PHP htaccess.
In this post we will show you Access-Control-Allow-Origin solution – Angularjs PHP Javascript and htaccess, hear for Access-Control-Allow-Origin solution – Angularjs PHP Javascript we will give you demo and example for implement.
In this post, we will learn about Angular .htaccess – htaccess Access-Control-Allow-Origin with an example.

Access-Control-Allow-Origin stands for other name is CORS (Cross-Origin Resource Sharing) header.

The Access-Control-Allow-Origin Resource Sharing standard works by adding new HTTP headers mean request that allow servers(permitted) to describe the set of origins(all) that are permitted to read(data read) that information using a web browser(chrome,mozila…).

READ :  Call to undefined function str_slug() in Laravel 6

It’s one type of Read permitted.

Solution for PHP – Using htaccess Access-Control-Allow-Origin

Error code or Angularjs,Javascript File Request in PHP

// Using Error Javascript File request to the server

type: “GET”,
web_url: “”,
data: “post_id=” + s_id + “&url_data=” + web_url,
dataType: ‘json’,
cache: false,
success: function(data)
var People_list_data = data[1];
var data_list = data[2];
$(‘#maindivid’).html(“Example of cors: “+People_list_data+”
Listing data view:


// Using Error Angularjs File request to the server


error genrated
//Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Server side code Solution

There just put in file

READ :  Vuejs dynemically slider - Vuejs image slider component example - Vuejs Carousel Slider Components

Solution No 1


Solution No 2


Solution No 3


Solution for htaccess – Using htaccess Access-Control-Allow-Origin

Go to Root Folder and First of all take a backup in htaccess file and past this code in .htaccessfile


Header set Access-Control-Allow-Origin “*”


Header set Access-Control-Allow-Origin
Header set Access-Control-Allow-Credentials true


How to Enable Access-Control-Allow-Origin chrome

please click this link and add the cors chrome extensions and after than send request.


A Simple requests of client side to server side send Request

A simple Access-Control-Allow-Origin or cross-site request is one that meets all the List of following conditions:

READ :  Vuejs Simple Bootstrap progress bar with percentage

The only allowed methods are:

Using GET Method
Using HEAD Method
Using POST Method

Apart from the headers(CORS) set automatically by the user agent (e.g. Connection, Content-Type,User-Agent, etc.), the only cors(headers) which are allowed to be manually header type set are below:


There are list of allow the Content-Type header are:


Leave a Comment