@@ -62,50 +62,54 @@ api.makeAgent = options => {
6262function createApp ( ) {
6363 const app = express ( ) ;
6464
65- app . use ( cors ( ) ) ;
66-
67- app . get ( '/ping' , ( req , res ) => {
65+ app . get ( '/ping' , cors ( ) , ( req , res ) => {
6866 res . json ( {
6967 pong : true
7068 } ) ;
7169 } ) ;
7270
73- app . get ( '/json' , ( req , res ) => {
71+ app . get ( '/json' , cors ( ) , ( req , res ) => {
7472 res . json ( {
7573 json : true
7674 } ) ;
7775 } ) ;
7876
79- app . get ( '/html' , ( req , res ) => {
77+ app . get ( '/html' , cors ( ) , ( req , res ) => {
8078 res . setHeader ( 'Content-Type' , 'text/html' ) ;
8179 res . send (
8280 '<!DOCTYPE html><html><head></head><body><p>HTML</p></body></html>'
8381 ) ;
8482 } ) ;
8583
8684 // emulate http://httpbin.org/status/404
87- app . get ( '/status/404' , ( req , res ) => {
85+ app . get ( '/status/404' , cors ( ) , ( req , res ) => {
8886 res . status ( 404 ) . send ( 'NOT FOUND' ) ;
8987 } ) ;
9088
9189 // emulate https://httpstat.us/404
92- app . get ( '/404' , ( req , res ) => {
90+ app . get ( '/404' , cors ( ) , ( req , res ) => {
9391 res . status ( 404 ) . json ( {
9492 code : 404 ,
9593 description : 'Not Found'
9694 } ) ;
9795 } ) ;
9896
99- app . get ( '/delay/:seconds' , async ( req , res ) => {
97+ app . get ( '/delay/:seconds' , cors ( ) , async ( req , res ) => {
10098 await delay ( req . params . seconds * 1000 ) ;
10199 res . status ( 200 ) . send ( ) ;
102100 } ) ;
103101
104- app . get ( '/headers' , ( req , res ) => {
102+ app . get ( '/headers' , cors ( ) , ( req , res ) => {
105103 res . json ( {
106104 headers : req . headers
107105 } ) ;
108106 } ) ;
109107
108+ app . get ( '/nocors' , ( req , res ) => {
109+ res . json ( {
110+ cors : false
111+ } ) ;
112+ } ) ;
113+
110114 return app ;
111115}
0 commit comments