-
Couldn't load subscription status.
- Fork 2k
Closed
Description
PHP Version
8.2
CodeIgniter4 Version
4.6.0
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
mysql
What happened?
I am using CodeIgniter 4 for the backend as an API for a Vue.js site, but I am encountering a CORS error when trying to communicate between them.
How can I fix this issue?
Steps to Reproduce
I have already applied the following configurations:
Cors.php file
public array $api = [
'allowedOrigins' => ['http://localhost:5173'],
'allowedOriginsPatterns' => [],
'supportsCredentials' => false,
'allowedHeaders' => ['Authorization', 'Content-Type','X-Requested-With'],
'exposedHeaders' => [],
'allowedMethods' => ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
'maxAge' => 7200,
];
Routes file
$routes->group('api/v1', ['namespace' => 'App\Controllers\Api','filter'=>'cors:api'], function (RouteCollection $routes) {
$routes->match(['post', 'options'], 'auth/signup', 'AuthController::signup', ['as' => 'api_signup']);
});
Controller Class
I am using:
class AuthController extends ResourceController
However, I am still getting a CORS error, and I can't resolve it.
For running the backend and frontend, I use:
php spark serve
npm run dev
Expected Output
Anything else?
No response
Metadata
Metadata
Assignees
Labels
No labels
