Skip to content

Instantly share code, notes, and snippets.

@sergey-kras
Created March 24, 2019 18:48
Show Gist options
  • Save sergey-kras/8523dd1429fbc9f8888c8fca019c041d to your computer and use it in GitHub Desktop.
Save sergey-kras/8523dd1429fbc9f8888c8fca019c041d to your computer and use it in GitHub Desktop.
serveronkoa
const Koa = require('koa'), // переделать на import
Router = require('koa-router'),
serve = require('koa-static'),
logger = require('koa-logger'),
bodyParser = require('koa-bodyparser'),
app = new Koa(),
router = new Router();
// app.use(bodyParser());
router.get('/login', async (ctx, next) => {
ctx.cookies.set('wtff', 'whats', { domain: 'localhost:3000', maxAge: '100000', path: '/'});
ctx.body = true;
console.log( ctx.cookies.get('sid'));
await next();
});
app.use(async (ctx, next) => {
ctx.set('Access-Control-Allow-Origin', 'http://localhost:3000');
ctx.set('Access-Control-Allow-Credentials', 'true');
await next();
});
// app.use(serve('public'));
app.use(logger());
app.use(router.routes());
app.listen(3001, () => { console.log('App listen on 3001'); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment