Comments (6)
@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.
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.
@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.
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.
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.
thanks it works @cgmartin and @maximedupre! keep with the good work
from lite-server.
Related Issues (20)
- Installation fails E429 too many Requests HOT 1
- Not listening on this port
- npm audit found vulnerabilities HOT 1
- npm is not started started script missing HOT 1
- i m trying to run npm start command but it is giving following error
- Problem with npm install HOT 2
- unable to start lite-server on wsl2 HOT 1
- Error using lite-server for create-react-app HOT 3
- The package needs to update axios to solve high severity vulnerability HOT 1
- Disable SPA handling? HOT 1
- lite-server doesn't trigger or reload the page when I save the page after adding something .
- CORS 404 OPTIONS HOT 2
- How to get Directory Listing working?
- Trying to start an html website using NPM and Lite-server HOT 2
- lite-server not installing using (npm install lite-server -g) HOT 1
- Lite-server dependecies are vulnerable (The Async package have a vulnerability)
- lite-server generating three Uncaught (in promise) errors after each reload
- Lite server disables CDN links
- Static files and api proxy HOT 1
- npm & github recommend not using: "All versions of package lite-server are vulnerable to Denial of Service"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lite-server.