I made an express server which generates issue to GitHub with Octokit. This worked if it is on localhost but doesn't work if it is deployed by Vercel.
Express Server
const express = require("express");
var app = express();
const octo = require("octokit");
const Octokit = octo.Octokit;
require("dotenv").config();
const octokit = new Octokit({
auth: process.env.GITHUB_ACCESS_TOKEN,
});
async function addIssue(title, description) {
await octokit.request("POST /repos/Jonathan0827/WonsinheungMid/issues", {
owner: "OWNER",
repo: "REPO",
title: title,
body: title,
labels: ["bug"],
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
});
console.log("success");
}
app.post("/report", function (req, res) {
res.send(req.query);
addIssue(req.query.title, req.query.desc);
});
app.listen(3000);
iOS App
struct params: Encodable {
let title: String
let desc: String
}
func generateIssue(title: String, description: String) {
let issue = params(title: title, desc: description)
AF.request("URL",
method: .post,
parameters: issue,
encoder: JSONParameterEncoder.default).response { response in
debugPrint(response)
}
}