Skip to content

Commit bedc8da

Browse files
added auth-callback function
1 parent fdc26ba commit bedc8da

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.netlify/functions/auth-callback.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
exports.handler = function(event, context, callback) {
2+
callback(null, {
3+
statusCode: 200,
4+
header: {
5+
"Content-Type": "text/html"
6+
},
7+
body: `
8+
<html>
9+
<body>
10+
<script>
11+
function getParameterByName(name, url_string) {
12+
var url = new URL(url_string);
13+
var c = url.searchParams.get("code");
14+
return c;
15+
}
16+
17+
(function Callback() {
18+
let githubCode = getParameterByName("code", window.location.href);
19+
console.log(githubCode)
20+
let targetWindow = window.opener;
21+
targetWindow.postMessage(githubCode, "*");
22+
})()
23+
</script>
24+
</body>
25+
</html>
26+
`
27+
});
28+
};

netlify.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[build]
22
command = "yarn site build"
33
publish = "./oss/public"
4+
functions = "./.netlify/functions"
45

56
[build.environment]
67
NODE_VERSION = "v11.14.0"

0 commit comments

Comments
 (0)