Skip to content

Commit bef354c

Browse files
committed
feat: v5.3.1
1 parent cd8222e commit bef354c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodepress",
3-
"version": "5.3.0",
3+
"version": "5.3.1",
44
"description": "RESTful API service for Surmon.me blog",
55
"author": "Surmon",
66
"license": "MIT",

src/modules/disqus/disqus.constant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { GUESTBOOK_POST_ID } from '@app/constants/biz.constant'
1010

1111
export const DISQUS_OAUTH_CALLBACK_URL = isProdEnv
1212
? `${APP_BIZ.URL}/disqus/oauth-callback`
13-
: `http://localhost:8000/disqus/oauth-callback`
13+
: `http://localhost:${APP_BIZ.PORT}/disqus/oauth-callback`
1414

1515
// extends
1616
export const COMMENT_POST_ID_EXTEND_KEY = 'disqus-post-id'

src/modules/disqus/disqus.controller.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class DisqusController {
4141
}
4242
}
4343

44+
@Get('close-window.js')
45+
closeWindowScript(@Response() response: FastifyReply) {
46+
response.type('application/javascript').send('window.close();')
47+
}
48+
4449
@Get('oauth-callback')
4550
async oauthCallback(@Query() query: CallbackCodeDTO, @Response() response: FastifyReply) {
4651
const accessToken = await this.disqusPublicService.getAccessToken(query.code)
@@ -57,9 +62,10 @@ export class DisqusController {
5762
secure: 'auto'
5863
})
5964
// Close the popup window
60-
response.header('content-security-policy', "script-src 'unsafe-inline'")
6165
response.header('content-type', 'text/html')
62-
response.send(`<script>window.close();</script>`)
66+
response.send(`<!DOCTYPE html><html><script src="/disqus/close-window.js"></script></html>`)
67+
// To maintain a secure `content-security-policy`, inline JavaScript is not used here.
68+
// response.send(`<script>window.close();</script>`)
6369
}
6470

6571
@Post('oauth-logout')

0 commit comments

Comments
 (0)