Cors Policy

Lukket Lagt ut 3 år siden Betales ved levering
Lukket Betales ved levering

Presently in my angular 9 application my post has the following header being set:

const httpOptions = {

headers: new HttpHeaders({

'Content-Type': 'application/json',

'Accept' : 'application/json'

})

};

Then in my laravel application, I have modified the [login to view URL] file as below:

protected function getRouteForMethods($request, array $methods)

{

if ($request->method() == 'OPTIONS') {

return (new Route('OPTIONS', $request->path(), function () use ($methods) {

//return new Response('', 200, ['Allow' => implode(',', $methods)]);

return new Response('', 200, [

'Allow' => implode(',', $methods),

'Access-Control-Allow-Origin' => '*',

'Access-Control-Allow-Credentials' => 'true',

'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS',

'Access-Control-Allow-Headers' => 'X-Requested-With, Content-Type, X-Auth-Token, Origin, Authorization'

]);

}))->bind($request);

}

$this->methodNotAllowed($methods);

}

Also in each of my laravel controller, I have included:

public function __construct(){

//header('Access-Control-Allow-Credentials: true');

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

}

However, after deployment to my VPS running on Centos operating system, I receive the following error when accessing from my browser:

Access to XMLHttpRequest at '[login to view URL]' from origin '[login to view URL]' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

With the settings above, on the localhost, the error above is resolved. However, when deployed to the production environment the problem crops out.

You are required to work on this remotely.

AngularJS Laravel CentOs

Prosjekt-ID: #25749906

Om prosjektet

4 bud Eksternt prosjekt Aktiv 3 år siden

4 frilansere byr i gjennomsnitt $25 for denne jobben

mho94

hi. I'm experienced in CORS, and I can resolve the issues of CORS at your production deployment. Can you please contact me. Thank you

$30 USD på 1 dag
(13 Omtaler)
4.5
raisdhaka

Hi, cors policy need to add at API, not at angular system. if you have access of that API, add header. if need my help, pls hire me. Thanks R

$35 USD på 1 dag
(5 Omtaler)
3.4
RajdeepWasekar

Hi This is a very simple solution. Just add the developer certificate in laravel. That will sort it out. Thanks

$15 USD på 7 dager
(0 Omtaler)
0.0
anjarwidiyatmoko

Hello, I have read your code, but perhaps something is missing need to check first. Contact me if you're interested for further discussion. Thanks.

$20 USD på 1 dag
(0 Omtaler)
0.0