Created
February 25, 2018 17:06
-
-
Save tony19/75b8b1e9c0136a9cebd78f0067d23a0a to your computer and use it in GitHub Desktop.
Running polyserve with URL-rewrite middleware
This file contains hidden or 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
const {startServer} = require('polyserve'); | |
const projectConfig = require('./polymer.json'); | |
const serverOptions = { | |
compile: projectConfig.compile, | |
entryPoint: projectConfig.entryPoint, | |
port: 8080, | |
root: 'src', | |
}; | |
(async () => { | |
await startServer(serverOptions, (app, options) => { | |
app.use((req, res, next) => { | |
if (req.url.startsWith('/foo')) { | |
req.url = req.url.replace(/^\/foo/, ''); | |
} | |
return next(); | |
}); | |
return app; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment