docs: 🐛 proxify api with netlify
Signed-off-by: slumbering <slumbering.pierrot@gmail.com>
This commit is contained in:
parent
128047b3aa
commit
bf03e5616e
15
netlify.toml
15
netlify.toml
@ -16,3 +16,18 @@
|
|||||||
# Do not build the site if there's no site-related changes since the last
|
# Do not build the site if there's no site-related changes since the last
|
||||||
# deploy.
|
# deploy.
|
||||||
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../docs/ ../netlify.toml"
|
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../docs/ ../netlify.toml"
|
||||||
|
|
||||||
|
[[redirects]]
|
||||||
|
from = "/github-proxy/*"
|
||||||
|
to = "https://github.com/:splat"
|
||||||
|
status = 200
|
||||||
|
|
||||||
|
[[redirects]]
|
||||||
|
from = "/github-api-proxy/*"
|
||||||
|
to = "https://api.github.com/:splat"
|
||||||
|
status = 200
|
||||||
|
|
||||||
|
[[redirects]]
|
||||||
|
from = "/docs-access/*"
|
||||||
|
to = "https://j20f3pfq11.execute-api.us-east-1.amazonaws.com/Prod/u/:splat"
|
||||||
|
status = 200
|
@ -21,7 +21,7 @@ function bindApiCall({ url, config, errorMessage }) {
|
|||||||
|
|
||||||
async function getAccessToken(code) {
|
async function getAccessToken(code) {
|
||||||
const accessToken = await bindApiCall({
|
const accessToken = await bindApiCall({
|
||||||
url: 'https://github.com/login/oauth/access_token',
|
url: '/github-proxy/login/oauth/access_token',
|
||||||
config: {
|
config: {
|
||||||
params: {
|
params: {
|
||||||
code,
|
code,
|
||||||
@ -37,7 +37,7 @@ async function getAccessToken(code) {
|
|||||||
|
|
||||||
export async function getUser(access_token) {
|
export async function getUser(access_token) {
|
||||||
const user = await bindApiCall({
|
const user = await bindApiCall({
|
||||||
url: 'https://api.github.com/user',
|
url: '/github-api-proxy/user',
|
||||||
config: {
|
config: {
|
||||||
headers: { Authorization: `token ${access_token}` },
|
headers: { Authorization: `token ${access_token}` },
|
||||||
},
|
},
|
||||||
@ -57,7 +57,7 @@ export async function checkUserCollaboratorStatus(code) {
|
|||||||
const { login } = await getUser(access_token)
|
const { login } = await getUser(access_token)
|
||||||
|
|
||||||
const isUserCollaborator = await bindApiCall({
|
const isUserCollaborator = await bindApiCall({
|
||||||
url: `https://docs-access.dagger.io/u/${login}`,
|
url: `/docs-access/${login}`,
|
||||||
errorMessage: 'error checkUserCollaboratorStatus'
|
errorMessage: 'error checkUserCollaboratorStatus'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user