2

I am trying to configure webpack devserver to run in http://localhost:8080/myProject

instead of the root path localhost:8080

I already tried to configure

public: 'https://localhost:8080/myProject',

and

publicPath: '/myProject/'

settings but I can't make it work.

I also tried to play with the proxy settings but that seems wrong.

The reason why i need this change it's because the api server sends a cookie with path=/myProject.

What am I missing?

0

1 Answer 1

1

Are you trying to emulate some API or do you want to get your front-end app at /myProject? If you want front-end at /myProject you don't need to edit a devserver, you just need to configure output in webpack.config.js:

output: {
  publicPath: '/myProject',
},

For emulating API you can use onBeforeSetupMiddleware in webpack.config.js:

devServer: {
  port: 3000,
  https: true,
  onBeforeSetupMiddleware: function (devServer) {
    devServer.app.get('/myProject', function (req, res) {
      res.json({
        message: 'some data from API'
      });
    });
  },
},
Sign up to request clarification or add additional context in comments.

1 Comment

The ideia was to get the frontend app at /myProject I no longer have that project but thanks for the answer

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.