facebook twitter hatena line email

Gcp/Firebase/CloudFunctions/request

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

getでのrequest

functions/index.js

exports.log1 = functions.https.onRequest((request, response) => {
  const errorlog = request.query['errorlog']
  console.error(errorlog);
  response.send("Hello from Firebase!log");
});

ttps://us-central1-unity-xxxxx.cloudfunctions.net/log1?errorlog=hoge

postでのrequest

functions/index.js

exports.log1 = functions.https.onRequest((request, response) => {
  if (request.method !== 'POST') {
    response.status(405).send('Method Not Allowed');
    return;
  }
  const errorlog = request.body.errorlog;
  console.error(errorlog);
  response.status(200).send(errorlog);
});

finished with status code: 304エラーが出る対応

response.set('Access-Control-Allow-Origin', '*');