Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:34:08+00:00 2026-06-11T15:34:08+00:00

I should preface this by the fact I am new to NodeJS, and more

  • 0

I should preface this by the fact I am new to NodeJS, and more generally to all the coding your own web server business, so please bear with me.

What I’m trying to achieve basically is replicating Apache’s alias mechanism. I should simply be able to configure a list of aliases and their corresponding path in a configuration file, then have Node serve the right resource depending on the request.

To achieve this I singled out two middleware to use on top of Connect: static and route. Route is mostly working as intended, but I have a problem grasping how static works. Specifically, my question right now would be : Is it possible to define multiple “statics” to use with connect and then choose which one you want to actually serve files through after receiving a request?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:34:09+00:00Added an answer on June 11, 2026 at 3:34 pm

    You can define multiple static to use with connect.

       app.use(express.static(__dirname + '/public1'));
       app.use(express.static(__dirname + '/public2'));
    

    The connect middleware will check if the file exists in the first directory and if not found it will check the next one.

    But static means static you shouldn’t use with req.

    If you wish to serve files based on the req then you should set-up a dynamic route that can serve content based on the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I should preface this question by saying that I am new to JavaServer Pages.
I should preface this with the fact that I know virtually nothing about javascript
Preface : I'm honestly not sure if this should be on StackOverflow, SuperUser or
As a preface, I am brand new to using SQL Server 2005; I know
I should preface this by saying that I am an undergrad CS student with
BACKGROUND: I should preface this by saying I'm not trying to get someone to
Let me preface this by saying I am extremely new to git but have
I should preface this by saying I'm working on a pocket PC app and
I should preface this question by saying I think the answer is probably no,
I want to preface this question with the fact that I am a student

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.