1

I'm working on a vue/cli 3 project. My vue.config.js is

module.exports = {
  publicPath: process.env.NODE_ENV == 'production' ? '/admin/' : '/',
  devServer: {
    proxy: {
      '/serveradmin': {
        target: 'http://localhost:8080/serveradmin',
      },
      "/assets/*": {
        target: "http://localhost:8080/assets",
        logLevel: 'debug',
        changeOrigin: true,
        secure: false,
      },
    },
  },
};

Using curl -v -X "HEAD" http://localhost:8081/assets/css/main.css, I get a 404. The console shows:

  App running at:
  - Local:   http://localhost:8081/ 
  - Network: http://192.168.1.155:8081/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

[HPM] HEAD /assets/css/main.css -> http://localhost:8080/assets

I've tried fiddling with pathRewrite, and it doesn't change the results. Changing the proxy key to "/assets" doesn't make any difference. What am I doing wrong?

1 Answer 1

1

The target property should be the base URL to which the original path is appended. With your current config, the request would be for http://localhost:8080/assets/assets/css/main.css (notice the two assets).

Remove the /assets suffix from your target URL:

// target: "http://localhost:8080/assets",
target: "http://localhost:8080",
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.