For Workes & Pages, what is the name of the domain?
https://weekly-rss.rivenqinyy.workers.dev/
What is the error number?
403
What is the error message?
response code 403
What is the issue or error you’re encountering
I simply request issues from a public warehouse, but a 403 error is returned every time. What should I do?
What steps have you taken to resolve the issue?
I switched several public warehouses, but still returned 403. Then I modified the request header and provided the token, but it didn’t work.
my code:
/**
- Welcome to Cloudflare Workers! This is your first worker.
-
- Run
npm run dev
in your terminal to start a development server
- Run
-
- Open a browser tab at http://localhost:8787/ to see your worker in action
-
- Run
npm run deploy
to publish your worker
- Run
- Bind resources to your worker in
wrangler.toml
. After adding bindings, a type definition for the Env
object can be regenerated withnpm run cf-typegen
.- Learn more at Cloudflare Workers · Cloudflare Workers docs
*/
export interface Env {
GITHUB_TOKEN: string;
}
async function getIssues(token: string) {
const headers = {
‘Content-Type’: ‘application/json’,
// @ts-ignore
Authorization: bearer ${token}
,
accept: ‘application/vnd.github.v3+json’,
};
console.log('headers', headers);
const response = await fetch('https://api.github.com/repos/primefaces/primevue/issues', {
headers,
});
if (response.ok) {
const data = await response.json();
return data;
} else {
console.log('error fetching issues', response);
throw new Error('Failed to fetch issues');
}
}
export default {
async fetch(request, env, ctx): Promise {
const issues = await getIssues(env.GITHUB_TOKEN);
// github api
return Response.json(issues);
},
} satisfies ExportedHandler;