New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

connect-tryfiles

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-tryfiles

nginx try_files style connect middleware: serve local file if exists or proxy to address

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
104
increased by141.86%
Maintainers
1
Weekly downloads
 
Created
Source

connect-tryfiles

Build status

nginx try_files style connect middleware: serve local file if exists or proxy to address

Idea

If a local file is available at the path corresponding to the URL, this middleware will do nothing (giving the chance to some other middleware serve it). Else, it will proxy the request to the given target. This way, you can serve local files easily and proxy the rest to your remote server.

Usage

connect = require 'connect'
http = require 'http'
tryfiles = require 'connect-tryfiles'

app = connect()
    .use(tryfiles('**', 'http://localhost:9000', {cwd: 'files'}))
    .use(connect.static('./files'))

server = http.createServer(app).listen(8000)

Assuming there is

  • a file at ./files/foo
  • a different server listening at localhost:9000 that returns "world" to any request

Requests to:

  • http://localhost:8000/foo will retrieve the file at files/foo
  • http://localhost:8000/hello will return "world"

FAQs

Package last updated on 06 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc