Skip to content

Commit 5052c1c

Browse files
added auth directory
1 parent bedc8da commit 5052c1c

File tree

3 files changed

+47
-19
lines changed

3 files changed

+47
-19
lines changed

.netlify/functions/auth-callback.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ exports.handler = function(event, context, callback) {
55
"Content-Type": "text/html"
66
},
77
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-
`
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+
`
2727
});
2828
};

now.json

+8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@
1010
{
1111
"src": "packages/server/dist/src/index.js",
1212
"use": "@now/node-server@canary"
13+
},
14+
{
15+
"src": "packages/auth/index.html",
16+
"use": "@now/static"
1317
}
1418
],
1519
"routes": [
1620
{
1721
"src": "/(.*)",
1822
"dest": "packages/server/dist/src/index.js"
23+
},
24+
{
25+
"src": "/auth",
26+
"dest": "packages/auth/index.html"
1927
}
2028
]
2129
}

packages/auth/index.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
3+
<body>
4+
<script>
5+
function getParameterByName(name, url_string) {
6+
var url = new URL(url_string);
7+
var c = url.searchParams.get("code");
8+
return c;
9+
}
10+
11+
(function Callback() {
12+
let githubCode = getParameterByName("code", window.location.href);
13+
console.log(githubCode)
14+
let targetWindow = window.opener;
15+
targetWindow.postMessage(githubCode, "*");
16+
})()
17+
</script>
18+
</body>
19+
20+
</html>

0 commit comments

Comments
 (0)