I am adding Stripe payment gateway to Laravel project and Aden I start requesting subscription to package using test mode and I get the following error
Can you please tell me why and how to fix it
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.
This is the code function that I am implementing
code
public function subscriptions_checkout(Request $request, string $plan)
{
return $request->user()
->newSubscription('default', $plan)
->checkout([
'success_url' => route('success_checkout'),
'cancel_url' => route('plans'),
]);
}
end code
You should Check your Cors.php in config. There you should add localhost:3000 if u are running local.
'paths' => ['*'],
'allowed_methods' => ['*'],
'allowed_origins' => [env('FRONTEND_URL', 'http://localhost:3000')],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
CORS are built-in in your browser so it might be a client sided thing. If the error still continues try adding CORS extension in your browser for development purposes. This should be good enough to get you go during development.