У меня есть сервис Google Cloud Run, который я пытаюсь позвонить из своего расширения Chrome, но запрос не удается. Вот моя настройка и проблемы, с которыми я сталкиваюсь. Используя Curl, я получаю конкретную ошибку SSL: curl: (60) SSL: нет альтернативного сертификата имени субъекта соответствует целевому имени хоста «Командовый процессор- [project_id] -Us-central1.run.app '< /code> < /p>
То, что я проверял: < /p>
. Ошибки. /> < /ul>
Это, по -видимому, является проблемой SSL -сертификата или отображения на самой службе Cloud Run. Почему служба по умолчанию на URL .RUN.APP будет отбывать несоответствующий сертификат, и каковы шаги в Google Cloud отладки или отталкивать сертификат SSL для Сервиса?// index.js (Corrected for Google Cloud Functions Framework)
const functions = require('@google-cloud/functions-framework');
const { google } = require('googleapis');
// This is the correct way to use cors with this framework
const cors = require('cors')({ origin: true });
// IMPORTANT: Replace this with your actual API key if needed.
const API_KEY = '**************';
// This is the single entry point for your Cloud Function
functions.http("commandProcessor", (req, res) => {
// The cors function handles the OPTIONS pre-flight request and then calls the callback.
cors(req, res, async () => {
try {
// --- Route 1: Handle the new /summarize-chat endpoint ---
if (req.path === '/summarize-chat') {
if (req.method !== 'POST') {
return res.status(405).send('Method Not Allowed');
}
console.log("Handling request for /summarize-chat");
const transcript = req.body.transcript;
if (!transcript) {
return res.status(400).json({ error: 'No transcript provided.' });
}
const summary = `### Chat Session Summary\n**Date:** ${new Date().toISOString()}\n\n**Raw Transcript:**\n---\n${transcript}\n---`;
return res.status(200).json({ summary: summary });
}
// --- Route 2: Handle all other requests as Drive commands (your original logic) ---
console.log("Handling request for Drive command processor.");
if (req.get('x-api-key') !== API_KEY) {
console.error("Unauthorized request: API key missing or incorrect.");
return res.status(401).send('Unauthorized');
}
if (req.method !== 'POST') {
return res.status(405).send('Method Not Allowed. Only POST is supported.');
}
const commandObject = req.body;
// ... (The rest of your original Drive command logic starts here and is unchanged)
if (!commandObject || !commandObject.command || !commandObject.parameters) {
console.error("Invalid command format received. Expected {command: 'CMD', parameters: [...]}.");
return res.status(400).send("Invalid command format.");
}
const authHeader = req.get('Authorization');
let userAuthToken = null;
if (authHeader && authHeader.startsWith('Bearer ')) {
userAuthToken = authHeader.substring(7);
} else {
console.warn("No Bearer token provided by client. This command might fail if it requires user-specific Drive access.");
}
console.log(`Cloud Run: Received raw command object: ${JSON.stringify(commandObject)}`);
console.log(`Cloud Run: Command extracted for switch: ${commandObject.command.toUpperCase()}`);
let result;
switch (commandObject.command.toUpperCase()) {
case 'DRIVE_CREATE_PROJECT':
result = await createProjectInDrive(commandObject.parameters[0], userAuthToken);
break;
// Add your other cases for DRIVE_CREATE_FILE, DRIVE_MOVE_FILE, etc. back in here
default:
result = { success: false, message: `Unknown Drive command: ${commandObject.command}.` };
break;
}
if (result.success) {
res.status(200).json({ status: 'success', message: result.message, data: result.data });
} else {
res.status(500).json({ status: 'error', message: result.message });
}
} catch (error) {
console.error('Unhandled error in function:', error);
res.status(500).json({ status: 'error', message: `Internal server error: ${error.message}` });
}
});
});
// --- All existing Google Drive helper functions remain here, unchanged ---
async function getDriveClient(token) {
// ... (your existing function)
}
async function createProjectInDrive(projectName, token) {
// ... (your existing function)
}
// ... etc for all other helper functions.
< /code>
manifest file (manifest.json): < /p>
{
"manifest_version": 3,
"name": "My Life AI Drive Extension",
"version": "1.2",
"description": "A private extension to allow My Life AI (Bob) to assist with Google Drive file management.",
"permissions": [
"identity",
"storage",
"notifications",
"downloads"
],
"host_permissions": [
"https://*.google.com/",
"https://*.googleapis.com/",
"https://https://command-processor-[PROJ ... 1.run.app/*"
],
"background": {
"service_worker": "background.js"
},
"action": {
"default_popup": "popup.html",
"default_title": "My Life AI Drive Commands"
},
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"oauth2": {
"client_id": "[YOUR_OAUTH_CLIENT_ID].apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/drive"
]
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... rom-chrome
Служба Cloud Run имеет ошибку сертификата SSL, что вызывает не удалось получить из расширения Chrome Extension ⇐ Javascript
Форум по Javascript
1750084130
Anonymous
У меня есть сервис Google Cloud Run, который я пытаюсь позвонить из своего расширения Chrome, но запрос не удается. Вот моя настройка и проблемы, с которыми я сталкиваюсь. Используя Curl, я получаю конкретную ошибку SSL: curl: (60) SSL: нет альтернативного сертификата имени субъекта соответствует целевому имени хоста «Командовый процессор- [project_id] -Us-central1.run.app '< /code> < /p>
То, что я проверял: < /p>
. Ошибки. /> < /ul>
Это, по -видимому, является проблемой SSL -сертификата или отображения на самой службе Cloud Run. Почему служба по умолчанию на URL .RUN.APP будет отбывать несоответствующий сертификат, и каковы шаги в Google Cloud отладки или отталкивать сертификат SSL для Сервиса?// index.js (Corrected for Google Cloud Functions Framework)
const functions = require('@google-cloud/functions-framework');
const { google } = require('googleapis');
// This is the correct way to use cors with this framework
const cors = require('cors')({ origin: true });
// IMPORTANT: Replace this with your actual API key if needed.
const API_KEY = '**************';
// This is the single entry point for your Cloud Function
functions.http("commandProcessor", (req, res) => {
// The cors function handles the OPTIONS pre-flight request and then calls the callback.
cors(req, res, async () => {
try {
// --- Route 1: Handle the new /summarize-chat endpoint ---
if (req.path === '/summarize-chat') {
if (req.method !== 'POST') {
return res.status(405).send('Method Not Allowed');
}
console.log("Handling request for /summarize-chat");
const transcript = req.body.transcript;
if (!transcript) {
return res.status(400).json({ error: 'No transcript provided.' });
}
const summary = `### Chat Session Summary\n**Date:** ${new Date().toISOString()}\n\n**Raw Transcript:**\n---\n${transcript}\n---`;
return res.status(200).json({ summary: summary });
}
// --- Route 2: Handle all other requests as Drive commands (your original logic) ---
console.log("Handling request for Drive command processor.");
if (req.get('x-api-key') !== API_KEY) {
console.error("Unauthorized request: API key missing or incorrect.");
return res.status(401).send('Unauthorized');
}
if (req.method !== 'POST') {
return res.status(405).send('Method Not Allowed. Only POST is supported.');
}
const commandObject = req.body;
// ... (The rest of your original Drive command logic starts here and is unchanged)
if (!commandObject || !commandObject.command || !commandObject.parameters) {
console.error("Invalid command format received. Expected {command: 'CMD', parameters: [...]}.");
return res.status(400).send("Invalid command format.");
}
const authHeader = req.get('Authorization');
let userAuthToken = null;
if (authHeader && authHeader.startsWith('Bearer ')) {
userAuthToken = authHeader.substring(7);
} else {
console.warn("No Bearer token provided by client. This command might fail if it requires user-specific Drive access.");
}
console.log(`Cloud Run: Received raw command object: ${JSON.stringify(commandObject)}`);
console.log(`Cloud Run: Command extracted for switch: ${commandObject.command.toUpperCase()}`);
let result;
switch (commandObject.command.toUpperCase()) {
case 'DRIVE_CREATE_PROJECT':
result = await createProjectInDrive(commandObject.parameters[0], userAuthToken);
break;
// Add your other cases for DRIVE_CREATE_FILE, DRIVE_MOVE_FILE, etc. back in here
default:
result = { success: false, message: `Unknown Drive command: ${commandObject.command}.` };
break;
}
if (result.success) {
res.status(200).json({ status: 'success', message: result.message, data: result.data });
} else {
res.status(500).json({ status: 'error', message: result.message });
}
} catch (error) {
console.error('Unhandled error in function:', error);
res.status(500).json({ status: 'error', message: `Internal server error: ${error.message}` });
}
});
});
// --- All existing Google Drive helper functions remain here, unchanged ---
async function getDriveClient(token) {
// ... (your existing function)
}
async function createProjectInDrive(projectName, token) {
// ... (your existing function)
}
// ... etc for all other helper functions.
< /code>
manifest file (manifest.json): < /p>
{
"manifest_version": 3,
"name": "My Life AI Drive Extension",
"version": "1.2",
"description": "A private extension to allow My Life AI (Bob) to assist with Google Drive file management.",
"permissions": [
"identity",
"storage",
"notifications",
"downloads"
],
"host_permissions": [
"https://*.google.com/",
"https://*.googleapis.com/",
"https://https://command-processor-[PROJECT_ID]-us-central1.run.app/*"
],
"background": {
"service_worker": "background.js"
},
"action": {
"default_popup": "popup.html",
"default_title": "My Life AI Drive Commands"
},
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"oauth2": {
"client_id": "[YOUR_OAUTH_CLIENT_ID].apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/drive"
]
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79667768/cloud-run-service-has-ssl-certificate-error-causing-failed-to-fetch-from-chrome[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия