Created
November 11, 2015 21:21
-
-
Save amenuor/e7d1508a0bde196758b8 to your computer and use it in GitHub Desktop.
CORS on GraphQL Server from relay-starter-kit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import cors from 'cors'; | |
import graphQLHTTP from 'express-graphql'; | |
import path from 'path'; | |
import webpack from 'webpack'; | |
import WebpackDevServer from 'webpack-dev-server'; | |
import {Schema} from './data/schema'; | |
const APP_PORT = 3000; | |
const GRAPHQL_PORT = 8080; | |
// Expose a GraphQL endpoint | |
var graphQLServer = express(); | |
graphQLServer.use(cors()); | |
graphQLServer.use('/', graphQLHTTP({ | |
graphiql: true, | |
pretty: true, | |
schema: Schema, | |
})); | |
graphQLServer.listen(GRAPHQL_PORT, () => console.log( | |
`GraphQL Server (CORS enabled) is now running on http://localhost:${GRAPHQL_PORT}` | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment