Skip to content

Commit

Permalink
fix: router config
Browse files Browse the repository at this point in the history
  • Loading branch information
kendallstrautman committed Mar 13, 2020
1 parent c30640d commit 73c1e41
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions server.js
@@ -1,4 +1,3 @@
const path = require('path')
const express = require('express')
const next = require('next')
const cors = require('cors')
Expand All @@ -7,29 +6,29 @@ const gitApi = require('@tinacms/api-git')
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({
dev,
dir: './src'
dev,
dir: './src',
})
const handle = app.getRequestHandler()

app.prepare().then(() => {
const server = express()
const server = express()

server.use(cors())
server.use(
'/___tina',
gitApi.router({
pathToRepo: path.join(process.cwd(), '../..'),
pathToContent: 'src'
})
)
server.use(cors())
server.use(
'/___tina',
gitApi.router({
pathToRepo: process.cwd(),
pathToContent: '',
})
)

server.all('*', (req, res) => {
return handle(req, res)
})
server.all('*', (req, res) => {
return handle(req, res)
})

server.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
server.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

0 comments on commit 73c1e41

Please sign in to comment.