@@ -4,19 +4,13 @@ import axios from "axios";
4
4
import * as cheerio from "cheerio" ;
5
5
import { pronounce } from "node-pronounce" ;
6
6
import randomUseragent from "random-useragent" ;
7
+ import { setDefaultHeaders } from "../utils/headers.js" ;
7
8
const rua = randomUseragent . getRandom ( ) ;
8
9
var wordOfDay = [ ] ;
9
10
const baseUrl = 'https://randomword.com' ;
10
11
11
12
router . get ( "/" , function ( req , res ) {
12
- res . header ( "Access-Control-Allow-Origin" , "*" ) ;
13
- res . header ( 'Access-Control-Allow-Headers' , 'Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With' ) ;
14
- res . header ( "Access-Control-Allow-Methods" , "GET" ) ;
15
- res . header ( "X-Frame-Options" , "DENY" ) ;
16
- res . header ( "X-XSS-Protection" , "1; mode=block" ) ;
17
- res . header ( "X-Content-Type-Options" , "nosniff" ) ;
18
- res . header ( "Strict-Transport-Security" , "max-age=63072000" ) ;
19
- res . setHeader ( "Content-Type" , "application/json" ) ;
13
+ setDefaultHeaders ( res ) ;
20
14
21
15
axios ( {
22
16
method : "GET" ,
@@ -70,14 +64,7 @@ router.get("/", function (req, res) {
70
64
} ) ;
71
65
72
66
router . get ( "/:pos" , function ( req , res ) {
73
- res . header ( "Access-Control-Allow-Origin" , "*" ) ;
74
- res . header ( 'Access-Control-Allow-Headers' , 'Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With' ) ;
75
- res . header ( "Access-Control-Allow-Methods" , "GET" ) ;
76
- res . header ( "X-Frame-Options" , "DENY" ) ;
77
- res . header ( "X-XSS-Protection" , "1; mode=block" ) ;
78
- res . header ( "X-Content-Type-Options" , "nosniff" ) ;
79
- res . header ( "Strict-Transport-Security" , "max-age=63072000" ) ;
80
- res . setHeader ( "Content-Type" , "application/json" ) ;
67
+ setDefaultHeaders ( res ) ;
81
68
82
69
const partOfSpeech = req . params . pos ;
83
70
@@ -132,4 +119,4 @@ router.get("/:pos", function (req, res) {
132
119
} ) ;
133
120
} ) ;
134
121
135
- export default router ;
122
+ export default router ;
0 commit comments