"modules" => [
"client-api" => [
"class" => "app\modules\clientapi\Module",
"components" => [
"user" => [
"class" => "yii\web\User",
"identityClass" => "app\modules\clientapi\models\Auth"
],
]
],
],
public function behaviors(){
$behaviors = parent::behaviors();
unset($behaviors['authenticator']);
$behaviors ['authenticator'] = [
'class' => HttpBearerAuth::className(),
'header' => Yii::$app->params["headers"]["token"],
'pattern' => '/^(.*?)$/',
'except' => [
'test',
'login',
'logout',
'reset-password',
'reset-password-confirm'
]
];
return $behaviors;
}
"modules" => [
"client-api" => [
"class" => "app\modules\clientapi\Module",
"components" => [
"user" => [
"class" => "yii\web\User",
"identityClass" => "app\modules\clientapi\models\Auth"
],
]
],
],
{
"name": "Exception",
"message": "Call to undefined method app\\models\\User::findIdentityByAccessToken()",
"code": 0,
"type": "Error",
"file": "X:\\project.loc\\vendor\\yiisoft\\yii2\\web\\User.php",
"line": 298,
}
app\models\Userпри запросе к АПИ
"modules" => [
"client-api" => [
"class" => "app\modules\clientapi\Module",
"components" => [
"client" => [
"class" => "yii\web\User",
"identityClass" => "app\modules\clientapi\models\Auth"
],
]
],
],
map $http_user_agent $limit_bots {
default 0;
~*(GoogleBot|YandexBot|TwitterBot|TelegramBot) 1;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name site.com;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:3333; // SPA
// proxy_pass http://127.0.0.1:4444; // SSR
}
}
location / {
if ($limit_bots = 1) {
// открыть порт 3333 для всех
} else {
// открыт порт 4444 только для поисковые и ботов соц.сета
}
}
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"live": "pm2 start npm --name 'prod-app' -- run start"
}