Skip to content

Commit f2a6085

Browse files
committed
Enable cross-origin requests in development mode
1 parent 0c1bfef commit f2a6085

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/gatsby/src/commands/develop.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ async function startServer(program) {
9393
})
9494
)
9595

96+
// Allow requests from any origin. Avoids CORS issues when using the `--host` flag.
97+
app.use((req, res, next) => {
98+
res.header(`Access-Control-Allow-Origin`, `*`)
99+
res.header(`Access-Control-Allow-Headers`, `Origin, X-Requested-With, Content-Type, Accept`)
100+
next()
101+
})
102+
96103
/**
97104
* Refresh external data sources.
98105
* This behavior is disabled by default, but the ENABLE_REFRESH_ENDPOINT env var enables it

0 commit comments

Comments
 (0)