Giter VIP home page Giter VIP logo

local-web-server's People

Contributors

75lb avatar gander avatar s-kulikov avatar sidesinger avatar web-padawan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

local-web-server's Issues

morgan deprecated

› ws
morgan deprecated morgan(options): use morgan("default", options) instead ../../../.nvm/v0.10.26/lib/node_modules/local-web-server/bin/ws.js:107:17
morgan deprecated default format: use combined format ../../../.nvm/v0.10.26/lib/node_modules/local-web-server/bin/ws.js:107:17
serving at http://localhost:8000

Configuring virtual host

Is there a way to implement virtual host config?
For now, I simply add my host alias into /etc/hosts and it proxifies me to 127.0.0.1
But in my opinion it would be nice to be able to configure it.

I looked for koa adapter and found two versions: koa-vhost and vhost-koa.
Both are developed for older koa versions.
I tried first of those, but it seems that I'm doing something wrong. The way I include it is like this:

  if (options.host) {
    const vhost = require('koa-vhost')
    debug('host', options.host)
    app.use(vhost({
      host: options.host,
      app: app
    }))
  }

ext-js memory leak?!

im working with ext-js 6
i compile my app as development (sencha app build development) and use ws
for local js files and as a proxy to my server calls which runs on tomcat.

with every refresh of the page it becomes slower and slower.

worth to mention that ext-js has a cache buster in the URL, maybe its that.
maybe its the multiple calls.

there are 804 requests done from the browser when loading the page.

anyway its really annoying to refresh it every time, if you need further information, ill be glad to give you anything you need.

Proxy: add resource-filtering feature

Proxy servers (e.g. Charles) have the usual ability to filter out unwanted resources (e.g. scripts) from the servers they proxy to.. Would be useful in local-web-server.

request.body is undefined in POST and PUT requests

As the title says. I thought that maybe I am doing something wrong, but then I took the examples from repository (https://github.com/75lb/local-web-server/tree/master/example/mock) and the same problem occurs. PUT request to /users/1 is in fact removing the user, because there is no ctx.request.body and POST request to /users adds object with just "id" property to the users array. It's the most useful feature of mocks for me and sadly it is not working.

I've googled a bit and the problem seems to be related to Koa bodyparser. Tried to fix it myself, but I don't have enough knowledge about Koa to understand what exactly is going wrong and why.

Merge rewrite rules from multiple .local-web-server.json files

If we have two .local-web-server.json files, say in the current directory and in the user's $HOME, configurations like port get merged properly, but if both files have rewrite rules, then only the rules in the current directory show up with ws --config.

Maybe it needs a deep merge?

Add ability to configure which hostname/IP the server listens on

Is there a way I can bind the server to 0.0.0.0 address
with http-server, we do this -a flag
http-server -a 0.0.0.0

with webpack-dev-server we do this with --host flag
webpack-dev-server --host 0.0.0.0

This would be very useful when we deploy it inside containers

Feature request: delay response

Is it possible to delay responses in some way? I tried implementing koa-slow, but no luck. Still instant response.

It would be cool to be able to implement some sort of delay for mocks. Maybe even with the use of a function, so that I can write my random delay e.g. between 50 and 1500 ms.

I'm not sure of that's out of scope for this project, maybe you have some other ideas?

Configuring Single Page App mode

Hi. I would like to use SPA mode to test my app. I my case the paths are entire URIs, for example

http://localhost:8000/http://some.uri.in.path

When I start the web server with ws -s index.html, such requests are not rewritten. ws logs a message saying

Not rewriting GET /http://some.uri.in.path because the path includes a dot (.) character

I understand it works under the assumption that dot signifies static content?

I tried --rewrite /* -> index.html but this causes any request, even when static files which exist, to respond with index.html.

Unable to run ws, argv.misc.config undefined?

Running on Ubuntu 15.04. Any ideas?

roo@roo-laptop:~/Development/react/one$ ws
/usr/local/lib/node_modules/local-web-server/bin/ws.js:70
if (argv.misc.config){
             ^
TypeError: Cannot read property 'config' of undefined
    at Object.<anonymous> (/usr/local/lib/node_modules/local-web-server/bin/ws.js:70:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

POST method not allowed

Hey there,
Whenever I try a POST request, I get the "Method Not Allowed" message.
Have I missed something in the configuration? or is local-web-server not intended to work with POST (as SimpleHTTPServer on python?).

Apart from that, thumbs up!

error message placement

err msg currently appears in Connection column, put somewhere else..

$ ws
serving at http://localhost:8000
Requests   Data        Connections
24         50.60 KB    Error: ENAMETOOLONG, stat '/Users/Lloyd/Documents/blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah'

Files not being served from rewrite rule after setting a SPA and root directory

Hi, I'm having an issue getting a rewrite rule to successfully serve files after setting a new root directory as a SPA. Basically, my folder directory is similar to this:

  • Project
    • app
      • index.html
    • node_modules
    • bower_components

Essentially, I'm launching the ws from the project root, setting app as the new root directory, setting index.html as the starting point for the SPA flag, and then trying to serve the bower_components folder to the app.

This is my launch command:
ws -d app --spa index.html -r '/bower_components/* -> ../bower_components/$1'

I'm getting a 403 error in terminal whenever the server tries to access the files. So I believe it's finding the folder, but can't serve it up. I've tried modifying the folder permissions with no success so far. Is there a way to do this currently? I might just be missing something completely. Any assistance would be greatly appreciated! Thanks!

Preset Management

Allow user to create, list, update, delete and run preset commands. E.g.

$ # open projects one and two on separate ports
$ ws ~/projects/one:8000 ~/projects/two:9000  

$ # give this command a name, for later use
$ ws ~/projects/one:8000 ~/projects/two:9000  --name current --desc "Two shitty projects"

$ # list presets
$ ws -l
Preset List
current - Two shitty projects

$ # launch your two projects from the preset
$ ws --preset current

please leave a +1 if you think this would help

add Mock Reponses

need a simple method define a mock responses.. a means of specifying, e.g. "any GET request to /api/camel should return mock camel data but a POST returns 403".

How can I add rewrite-rules?

Like in the npm-server "web-server-rewrite" I really need http-rewrite-rules with regular expressions. But:

  1. I really like your local-web-server
  2. I can't get the web-server-rewrite to work because of problems with the execSync-Dependency

What for is this? It's especially for services which need to be rewritten to another url in local and live-environment, e.g.:

rewrites

 {
    "localhost": {
      "(.*)(/users/)(.*)": "http://myserver1.mw.domain.lan:10080/middleware1/$3",
      "(.*)(/auth/)(.*)": "http://myserver2.mw.domain.lan:10080/auth-service/$3"
    },
   "domain.de": {
    ...
   }
 }

This would be very helpful - and if you include the keyword "rewrite" in your descriptions, this would definitely boost your server-implementation!

Regards
Markus

'Cannot find module' with mocks

Already scratched my head for far too long...

[22:57:00] Error: Cannot find module 'mocks\servers.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

Got this config:

lws({
    'static': {
        'root': './'
    },
    'mocks': [{
        'route': '/',
        'module': '/mocks/servers.js'
    }]
}).listen(2650)

Happens on line 151. Basically, it's not able to load the file. However, if I remove the 'module' property, the server starts (of course), and I'm able to navigate to /mocks/servers.js and get the content.

Error when trying to configure more than one rewrite

Seems like if I have more than one rewrite specified, I'm unable to start the server:

...\node_modules\local-web-server\node_modules\path-to-regexp\index.js:89
  if (index < str.length) {
                 ^

TypeError: Cannot read property 'length' of undefined
{
  "rewrite": [
    { "from:": "/PathOne/*", "to": "http://localhost/PathOne/$1" },
    { "from:": "/PathTwo/*", "to": "http://localhost/PathTwo/$1" },
    { "from": "/PathThree/*", "to": "http://localhost/PathThree/$1" }
  ]
}

Let me know if any other info would help.

Access-Control-Allow-Origin header not sent?

I'm running in single page application mode. I never see this header which is preventing api calls to my backend from working while in development mode.

The docs say this: CORS-friendly, all origins allowed by default. making me think it should be set by default.

Furthermore, I thought there would be a way to customize headers. I can't find any documentation that shows how to add specific headers to all request responses. Is that possible?

Thanks!

index.php is downloading itself

Hi,

First of all thank you for making such a handy project. I was looking for such a static local web server, it works well. But it keeps downloading *.php file as if it's not in server root.
I am on Ubuntu 14.04 platform.
What should I do to let server open *.php files in browser?

Regards

Kenn

need ability to specify config file

currently, ws merges config loaded from package.json and/or .local-web-server.json (depending on which exists).

Implement a --config-file (or similar) option to enable the user to specify a config file name. This would be useful for A/B testing, comparing server results using config A against config B.

iframe src looking at root of webpage instead of iframe src directory (spa?)

The set up is like the following:

localhost:8000
localhost:8000/web_page/index.html
localhost:8000/web_page/iframe/index.html
localhost:8000/web_page/iframe/scripts/some_script.js

The HTML is:
<iframe src="iframe"></iframe>

I start the server using the following command line:
ws --spa index.html

The error I get is:
GET http://localhost:8000/iframe 404 (Not Found)

I think the expected behavior is for the relative path of the iframe src value of "iframe" to look in the subdirectory "localhost:8000/web_page/iframe" and use the spa of "index.html" as well as all the contents inside the iframe should have the relative path of the src value.

This does not seem to work with the following iframe src values:

iframe
iframe/
iframe/index.html

This does seem to work with the following iframe src values:

web_page/iframe/
/web_page/iframe/

The following partially works, but the relative path of the elements in the iframe seem to look in the parent directory, "localhost:8000/web_page", instead of "localhost:8000/web_page/iframe" (tries to serve "localhost:8000/web_page/scripts/some_script.js" instead of "localhost:8000/web_page/iframe/scripts/some_script.js").

/web_page/iframe
web_page/iframe

(Sorry if I'm doing something dumb!)

JSON-requests not correctly proxied

PROXY-REWRITE:

local-web-server proxy request +0ms from: /loginservice/de/1234, to: http://myserver/login/de?myId=1234

local-web-server RESPONSE

curl -v -H "Content-Type:application/json" --data "@testrequest.json" "http://mylocalhost/loginservice/de/1234"

  • Hostname was NOT found in DNS cache
  • Connected to ... (...) port 8999 (#0)

    POST /loginservice/de/1234 HTTP/1.1
    User-Agent: curl/7.35.0
    Host: ...
    Accept: /
    Content-Type:application/json
    Content-Length: 122

  • upload completely sent off: 122 out of 122 bytes
    < HTTP/1.1 500 Internal Server Error
  • Server Apache-Coyote/1.1 is not blacklisted
    < server: Apache-Coyote/1.1
    < date: Wed, 16 Dec 2015 09:41:52 GMT
    < content-length: 0
    < connection: close

CORRECT RESPONSE VIA DIRECT CALL

  • upload completely sent off: 122 out of 122 bytes
    < HTTP/1.1 200 OK
    < Date: Wed, 16 Dec 2015 09:48:53 GMT
  • Server Apache-Coyote/1.1 is not blacklisted
    < Server: Apache-Coyote/1.1
    < Content-Type: application/json
    < Transfer-Encoding: chunked
    <
  • Connection #0 to host localhost left intact
    {"status":"SUCCESS","resultUri":"..."}

Issue with Running server

Have an issues with running server...:

For the record, package.json looks like in a sample:

{
  "name": "web-sever",
  "version": "1.0.0",
  "scripts": {
    "start": "ws"
  }
}

When I trying to run in terminal, here what I get:

local-user-mac:ws local-user$ npm start

> web-sever@1.0.0 start /Users/local-user/work/ws
> ws

sh: ws: command not found

npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! web-sever@1.0.0 start: `ws`
npm ERR! Exit status 127
npm ERR! 
npm ERR! Failed at the web-sever@1.0.0 start script 'ws'.
npm ERR! This is most likely a problem with the web-sever package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ws
npm ERR! You can get their info via:
npm ERR!     npm owner ls web-sever
npm ERR! There is likely additional logging output above.

Server says: level_15 or view access

When tried to access the test page in my mobile. A popup shows with the message

Authentication Required
The server at http://xxx.xx.x.x:80 requires a user name and password.
The server says level_15 or view_access

What to change in configuration setting to avoid this login?

more detailed stats

maybe something looking like:

Open connections Active clients Requests Transferred
6 1 30 43.4kb
Resource Downloads Total Transferred
/index/html 13 32kb
/js/app/js 3 600kb
/img/car.png 20 4.3mb
Type Downloads Transferred
.html 34 300kb
.jpg 323 3.2mb
.js 16 1.1mb

Browser Sync

Hi,

Awesome tool! Just one question - I am using Browser Sync and it seems to go into an endless refresh loop when hosting through the local-web-server. Is there a way around it? OR rather, is it possible to support rerouting of the ws:// protocol?

Thanks,
Johann

Can't start server with `--log-format none`

Starting with v0.5.20, it's not possible to disable console logging.

$ ws --log-format none

/Users/adam/.nvm/versions/node/v0.12.4/lib/node_modules/local-web-server/node_modules/connect/index.js:87
  if (typeof handle.handle === 'function') {
                   ^
TypeError: Cannot read property 'handle' of undefined
    at Function.use (/Users/adam/.nvm/versions/node/v0.12.4/lib/node_modules/local-web-server/node_modules/connect/index.js:87:20)
    at launchServer (/Users/adam/.nvm/versions/node/v0.12.4/lib/node_modules/local-web-server/bin/ws.js:113:9)
    at Object.<anonymous> (/Users/adam/.nvm/versions/node/v0.12.4/lib/node_modules/local-web-server/bin/ws.js:88:5)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

All other logging modes seem to work fine.

Koa version?

are there are benefits to switching from Connect to Koa?

Proxy: a remote hangup should not crash the server

if a remote proxy request fails for some reason (e.g. socket hang-up), ws crashes.. it should handle the exception, report the issue and carry on.

InternalServerError: [PROXY] socket hang up: http://lhtapp01:8180/resources/contents/copies/113864/draft?nocache=146315555730825777655849.375153
    at Object.throw (/Users/lloydb/Documents/75lb/local-web-server/node_modules/koa/lib/context.js:91:23)
    at ProxyServer.proxy.once.err (/Users/lloydb/Documents/75lb/local-web-server/lib/middleware.js:40:17)
    at ProxyServer.emit (/Users/lloydb/Documents/75lb/local-web-server/node_modules/eventemitter3/index.js:144:27)
    at ClientRequest.proxyError (/Users/lloydb/Documents/75lb/local-web-server/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:141:16)
    at emitOne (events.js:101:20)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketCloseListener (_http_client.js:282:9)
    at emitOne (events.js:101:20)
    at Socket.emit (events.js:188:7)
    at TCP._handle.close [as _onclose] (net.js:4ecc-ui lloydb:$

update Readme

  • mention default stats view
  • demo gifs?
  • tips how to use with Workspaces
  • document install locally, use with npm start
  • mention CORS friendly

Internal Server Error

Hello, I am trying to handle POST requests. I have probably done something wrong but I can not debug the Error. I receive "Internal Server Error" but there is no other info. I can not detect any log file. Any help, suggestion?

Is it possible to proxy request HTTP headers?

Hello!

Is it possible to proxy request HTTP headers? For instance, it would be great if I could send basic authentication header to test front-end with a real REST API. Adding login and password to URL in plain text does not work.

Thanks for any information.

Kind regards,
Vladimir

Default to compress?

Is there some reason it's not on my default? It adds negligible CPU load and is far and away a "best practice". Just found this after using http-server (which doesn't even offer the option to compress) and really like things so far (--spa rocks) but would be nice to avoid typing -c every time.

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.