Skip to content

Commit

Permalink
Add /admin/ aliases for other endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
lyind committed Oct 18, 2023
1 parent 0e73715 commit b8a1b21
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions app/staticcms/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@ app.use(publicHandler)
app.use('/admin', publicHandler)

// Serve CMS source files
const cmsHandler = express.static('./app/dist');
app.use('/cms', express.static('./app/dist'))
app.use('/admin/cms', express.static('./app/dist'))

app.get('/config.yml', (req, res) => {
const configHandler = (req, res) => {
res.sendFile(
'./config.yml',
{ root: path.join(__dirname, "..")
});
});
});
};
app.get('/config.yml', configHandler);
app.get('/admin/config.yml', configHandler);

// Pass requests to OAuth routes to `netlify-cms-github-oauth-provider` project
const oauth_provider_app = require('../netlify-cms-github-oauth-provider/app.js');
app.use('/auth', function(req, res, next) {
const authHandler = function(req, res, next) {
req.url = '/auth';
oauth_provider_app(req, res, next)
});
app.use('/callback', function(req, res, next) {
};
app.use('/auth', authHandler);
app.use('/admin/auth', authHandler);

const callbackHandler = function(req, res, next) {
req.url = '/callback';
oauth_provider_app(req, res, next)
});
};
app.use('/callback', callbackHandler);
app.use('/admin/callback', callbackHandler);

app.listen(port, () => {
console.log(`Static CMS listening on port ${port}`)
Expand Down

0 comments on commit b8a1b21

Please sign in to comment.