Created
July 3, 2016 22:47
-
-
Save charlieschwabacher/991a6892205df1802459ee6d742d950a to your computer and use it in GitHub Desktop.
corss origin server.js for blogs example
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 importAll from 'import-all'; | |
import gestaltServer from 'gestalt-server'; | |
import gestaltPostgres from 'gestalt-postgres'; | |
import cors from 'cors'; | |
const apiApp = express(); | |
apiApp.use(cors({ | |
origin: 'http://localhost:3000', | |
credentials: true, | |
})); | |
apiApp.use(gestaltServer({ | |
schemaPath: `${__dirname}/schema.graphql`, | |
objects: importAll(`${__dirname}/objects`), | |
mutations: importAll(`${__dirname}/mutations`), | |
database: gestaltPostgres({ | |
databaseURL: 'postgres://localhost/blogs_example' | |
}), | |
secret: '༼ つ ◕_◕ ༽つ', | |
development: true, | |
})); | |
apiApp.listen(3001); | |
const frontendApp = express(); | |
frontendApp.use(express.static(`${__dirname}/static`)); | |
frontendApp.get('/*', (req, res) => res.sendFile(`${__dirname}/static/index.html`)); | |
frontendApp.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment