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

  • Home
  • SEARCH
  • 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 6146583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:58:14+00:00 2026-05-23T18:58:14+00:00

My site is powered by node & using the Express framework. My goal is

  • 0

My site is powered by node & using the Express framework.
My goal is to setup a proxy to get data from the Yahoo Placefinder api (because they do not offer a JSONP response).
I want to send jquery ajax requests to the proxy and get back the PlaceFinder api response.

Here is my express route:

app.get('/placefinder/:curr_address', function (req, res) {

var options = {
    host: 'where.yahooapis.com',
    port: 80,
    path: '/geocode?location=' + req.params.curr_address + '&flags=J&appid=[put app id here]'
};

var req = http.get(options, function (res2) {
    console.log("Got response: " + res2.statusCode);

    res2.setEncoding('utf8');
    res2.on('data', function (chunk) {
        console.log('BODY: ' + chunk);

        res.render('response', {
            response: chunk
        }); // res.render
    }); // on
}); // req
req.on('error', function (e) {
    console.log("Got error: " + e.message + "... path: " + options.host + options.path);
});
// write data to request body
req.write('data\n');
req.write('data\n');});

The above code is working. For example, I can visit mywebsite.com/placefinder/123+fake+street,90210 and the response from the PlaceFinder api will be displayed.

The issue is that everyone can visit that page and get the response from the PlaceFinder api. I don’t want that. I only want my (ajax) scripts have access.

  1. How can I use some basic authentication to permit only my ajax requests to access mywebsite.com/placefinder/123+fake+street,90210 … I’ve never used basic authentication and I can’t figure out how to apply it to this case.

  2. Or, is there some way I can block the placefinder directory from all outside access (kind of like apache .htacess)?

  • 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-05-23T18:58:14+00:00Added an answer on May 23, 2026 at 6:58 pm

    How can I use some basic authentication to permit only my ajax
    requests to access mywebsite.com/placefinder/123+fake+street,90210 …
    I’ve never used basic authentication and I can’t figure out how to
    apply it to this case.

    I don’t think you should be using basic auth, but use sessions instead. TJ does have example available how to use session at https://github.com/visionmedia/express/tree/master/examples/session. There are a lot more examples available you should study. Connect does also have a middleware to handle basic auth though. I don’t like this approach, because it is not that safe especially when not used behind SSL.

    Or, is there some way I can block the placefinder directory from all
    outside access (kind of like apache .htacess)?

    In node.js every app runs in a separate process. You could just bind to just that host instead of INADDR_ANY.

    app.listen([port[, host]])

    Bind the app server to the given port, which defaults to 3000. When
    host is omitted all connections will be accepted via INADDR_ANY.

    app.listen(); app.listen(3000); app.listen(3000, ‘n.n.n.n’);

    You could also Use node.js with NGinx. Than you for example use something like https://serverfault.com/questions/183884/nginx-protect-directory-with-password-except-for-specific-ips/183939#183939. NGinx is very powerful.

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

Sidebar

Related Questions

I'm facing very strange issue, I'm getting JSON object from django powered site and
I've set up mvc-mini-profiler against my Entity Framework-powered MVC 3 site. Everything is duly
I'm about to deploy a mediumsized site powered by Django. I have a dedicated
What I want to do is pretty straightforward. I have a site powered by
For my django powered site, I am looking for an easy solution to convert
We have a legacy ASP.net powered site running on a IIS server, the site
I have some code on my PHP powered site that creates a random hash
We've got a server over which we're running a Django powered site. Since we
I'm working on a Drupal mobile site which is powered by the Mobile module.
Anyone know how to use Google Analytics for a Drupal-powered company intranet site behind

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.