GithubHelp home page GithubHelp logo

proxy about lite-server HOT 6 OPEN

gadieichhorn avatar gadieichhorn commented on August 20, 2024 3
proxy

from lite-server.

Comments (6)

cgmartin avatar cgmartin commented on August 20, 2024 15

@gadieichhorn here is a working example with lite-server

Run:

$ npm install --save-dev http-proxy-middleware connect-history-api-fallback

File: bs-config.js

var proxyMiddleware = require('http-proxy-middleware');
var fallbackMiddleware = require('connect-history-api-fallback');

module.exports = {
    server: {
        middleware: {
            1: proxyMiddleware('/api', {
                target: 'http://www.example.org',
                changeOrigin: true   // for vhosted sites, changes host header to match to target's host
            }),

            2: fallbackMiddleware({
                index: '/index.html', verbose: true
            })
        }
    }
};

from lite-server.

chimurai avatar chimurai commented on August 20, 2024 1

Thanks @cgmartin for the example.

Added lite-server to the list of examples:
https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md#lite-server

from lite-server.

cgmartin avatar cgmartin commented on August 20, 2024

@gadieichhorn This should be possible by adding a proxy middleware in a custom bs-config.js, ie: http-proxy-middleware
https://github.com/chimurai/http-proxy-middleware/blob/master/examples/browser-sync/index.js

from lite-server.

Joebob12 avatar Joebob12 commented on August 20, 2024

Has anyone been able to put in a bs-config file and get it working? I'm Actually getting in the terminal a "Did not detect a 'bs-config.json' or 'bs-config.js' overide file using lite-server defaults when I have it in my directory. See image of test project error here Not sure if i'm going crazy or not.

from lite-server.

maximedupre avatar maximedupre commented on August 20, 2024

I think the history middleware should be before the proxy middleware. For some reason, when the proxy middleware is first, it never reaches the history one.

from lite-server.

pabl-o-ce avatar pabl-o-ce commented on August 20, 2024

thanks it works @cgmartin and @maximedupre! keep with the good work

from lite-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.