@@ -4,19 +4,13 @@ import axios from "axios";
44import * as cheerio from "cheerio" ;
55import { pronounce } from "node-pronounce" ;
66import randomUseragent from "random-useragent" ;
7+ import { setDefaultHeaders } from "../utils/headers.js" ;
78const rua = randomUseragent . getRandom ( ) ;
89var wordOfDay = [ ] ;
910const baseUrl = 'https://randomword.com' ;
1011
1112router . 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 ) ;
2014
2115 axios ( {
2216 method : "GET" ,
@@ -70,14 +64,7 @@ router.get("/", function (req, res) {
7064} ) ;
7165
7266router . 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 ) ;
8168
8269 const partOfSpeech = req . params . pos ;
8370
@@ -132,4 +119,4 @@ router.get("/:pos", function (req, res) {
132119 } ) ;
133120} ) ;
134121
135- export default router ;
122+ export default router ;
0 commit comments