For this solution you do not need to activate headers_module in your list modules of apache server.
2.1-After installed your bundle, require the nelmio/cors-bundle package in your composer.json and update your dependencies.
$ composer require nelmio/cors-bundle
2.2-Add the NelmioCorsBundle to your application's kernel:
public function registerBundles()
{
$bundles = array(
...
new Nelmio\CorsBundle\NelmioCorsBundle(),
...
);
...
}
If you have same problem like No 'Access-Control-Allow-Origin' when you try to access Rest Api from another Uri, two solutions :
1- With configuration in your _.htaccess_ in web folder:
For this solution you need to activate headers_module in your list modules of apache server. After add this configuration :
2- With bundle _NelmioCorsBundle_ :
For this solution you do not need to activate headers_module in your list modules of apache server.
2.1-After installed your bundle, require the
nelmio/cors-bundle
package in your composer.json and update your dependencies.$ composer require nelmio/cors-bundle
2.2-Add the NelmioCorsBundle to your application's kernel:
2.3-Configuration