I would like Vue CLI's dev server to return a string when a specific URL is fetched. For this, I wanted to use webpack dev-server
's bypass
option. (webpack docs)
I tried this:
devServer: {
proxy: {
'/something': {
bypass: (req, res) => res.send(process.env.SOMETHING),
}
}
}
This causes an error: When proxy in package.json is an object, each context object must have a target property specified as a url string
.
I don't need a target
option (like in this example)
How can I make this work?
devServer.proxy
isn't appropriate for this. Instead, add your route indevServer.before
in Webpack 4 (used in Vue CLI 4):...or
devServer.onBeforeSetupMiddleware
in Webpack 5 (used in Vue CLI 5):