Skip to content

Instantly share code, notes, and snippets.

@charlieschwabacher
Created July 3, 2016 22:47
Show Gist options
  • Save charlieschwabacher/991a6892205df1802459ee6d742d950a to your computer and use it in GitHub Desktop.
Save charlieschwabacher/991a6892205df1802459ee6d742d950a to your computer and use it in GitHub Desktop.
corss origin server.js for blogs example
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