mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
docs: fix proxy setting
This commit is contained in:
parent
e9910c4a3e
commit
bd299c924e
|
@ -6,10 +6,12 @@ module.exports = async function (context, req) {
|
||||||
// https://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read,activity:read&state=strava
|
// https://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read,activity:read&state=strava
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const code = (req.query._code || (req.body && req.body.code));
|
const code = (req.query.code || req.query._code || (req.body && req.body.code));
|
||||||
const segment = (req.query.state || (req.body && req.body.state));
|
const segment = (req.query.state || (req.body && req.body.state));
|
||||||
if (!code || !segment) {
|
if (!code || !segment) {
|
||||||
|
context.log(`Issue processing request: missing code (${code}) or segment (${segment})`);
|
||||||
context.res = {
|
context.res = {
|
||||||
|
body: "not all query parameters are set",
|
||||||
status: 400
|
status: 400
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
|
@ -21,6 +23,7 @@ module.exports = async function (context, req) {
|
||||||
body = await strava.getStravaToken(code);
|
body = await strava.getStravaToken(code);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
context.log(`Unknown segment: ${segment}`);
|
||||||
context.res = {
|
context.res = {
|
||||||
body: "unknown segment",
|
body: "unknown segment",
|
||||||
status: 400
|
status: 400
|
||||||
|
@ -28,7 +31,7 @@ module.exports = async function (context, req) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `https://ohmyposh.dev/docs/auth?segment=${segment}&access_token=${body.access_token}&refresh_token=${body.refresh_token}`;
|
const url = `${process.env['DOCS_LOCATION']}/docs/auth?segment=${segment}&access_token=${body.access_token}&refresh_token=${body.refresh_token}`;
|
||||||
|
|
||||||
const res = {
|
const res = {
|
||||||
status: 302,
|
status: 302,
|
||||||
|
@ -39,7 +42,7 @@ module.exports = async function (context, req) {
|
||||||
};
|
};
|
||||||
context.done(null, res);
|
context.done(null, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
context.log(error);
|
context.log(`Issue processing request:\n${error}`);
|
||||||
context.res = {
|
context.res = {
|
||||||
body: error,
|
body: error,
|
||||||
status: 500
|
status: 500
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
"IsEncrypted": false,
|
"IsEncrypted": false,
|
||||||
"Values": {
|
"Values": {
|
||||||
"AzureWebJobsStorage": "",
|
"AzureWebJobsStorage": "",
|
||||||
"FUNCTIONS_WORKER_RUNTIME": "node"
|
"FUNCTIONS_WORKER_RUNTIME": "node",
|
||||||
|
"API_LOCATION": "http://localhost:7071",
|
||||||
|
"DOCS_LOCATION": "http://localhost:3000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
"$schema": "http://json.schemastore.org/proxies",
|
"$schema": "http://json.schemastore.org/proxies",
|
||||||
"proxies": {
|
"proxies": {
|
||||||
"callback": {
|
"callback": {
|
||||||
|
"debug": true,
|
||||||
"matchCondition": {
|
"matchCondition": {
|
||||||
"methods": ["GET", "POST"],
|
"methods": ["GET", "POST"],
|
||||||
"route": "/api/auth"
|
"route": "/api/auth"
|
||||||
},
|
},
|
||||||
"backendUri": "http://localhost/api/auth",
|
"backendUri": "%API_LOCATION%/api/auth",
|
||||||
"requestOverrides": {
|
"requestOverrides": {
|
||||||
"backend.request.querystring.code": "",
|
"backend.request.querystring.code": "",
|
||||||
"backend.request.querystring._code": "{request.querystring.code}"
|
"backend.request.querystring._code": "{request.querystring.code}"
|
||||||
|
|
Loading…
Reference in a new issue