Answer the question
In order to leave comments, you need to log in
Yii2 How to setup urlManager->rules for CRUD and accept preflight from front?
It was, but then preflight returns Not Found.
Path to api/default controller model. And, it is necessary that the relative path to api starts with api/v1/items, and not api/default/items.
I don’t understand how else I need to rewrite it so that both the path is api / v1 and preflight requests go through ...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
// 'PUT api/v1/<objects>/<id>' => 'api/default/update',
// 'DELETE api/v1/<objects>/<id>' => 'api/default/delete',
// 'POST api/v1/<objects>' => 'api/default/create',
// 'GET api/v1/<objects>' => 'api/default/index',
// 'GET api/v1/<objects>/<id>' => 'api/default/view',
],
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'api/default',
'patterns' => [
'PUT api/v1/<objects>/<id>' => 'update',
'DELETE api/v1/<objects>/<id>' => 'delete',
'POST api/v1/<objects>' => 'api/default/create',
'GET api/v1/<objects>' => 'api/default/index',
'GET api/v1/<objects>/<id>' => 'api/default/view',
// OPTTIONS VERBS
'OPTIONS api/v1/<objects>/<id>' => 'options',
'OPTIONS api/v1/<objects>/<id>' => 'options',
'OPTIONS api/v1/<objects>' => 'options',
'OPTIONS api/v1/<objects>/<id>' => 'options'
]
],
'api/v1/' => 'api/default/index',
'' => 'options',
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question