forked from miragejs/site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
33 lines (29 loc) · 899 Bytes
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
import "./src/styles/global.css"
import "./src/styles/tailwind-utils.css"
import "./src/fonts/Ginto/ginto.css"
import "./src/fonts/GTAmerica/gt-america.css"
import { createServer, Response } from "miragejs"
if (window.Cypress) {
let otherDomains = ["https://miragejs-site-backend.herokuapp.com/"]
let methods = ["get", "put", "patch", "post", "delete"]
createServer({
environment: "test",
routes() {
for (const domain of ["/", ...otherDomains]) {
for (const method of methods) {
this[method](`${domain}*`, async (schema, request) => {
let [status, headers, body] = await window.handleFromCypress(
request
)
return new Response(status, headers, body)
})
}
}
},
})
}