Skip to content

How can I rewrite path from "/api/products" to "/mock/products.json" ? #333

@GF-Huang

Description

@GF-Huang

I'm using webpack for vuejs, this is my config, but not works:

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        pathRewrite(path, req) {
          return (path.replace('/api', '/mock') + '.json')
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions