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 6702483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:03:34+00:00 2026-05-26T07:03:34+00:00

I’m trying to use Node.js to set up a proxy to Last.fm’s webservices. The

  • 0

I’m trying to use Node.js to set up a proxy to Last.fm’s webservices. The problem is that every request to ws.audioscrobbler.com gets rewritten to http://www.last.fm. So for example $ curl http://localhost:8000/_api/test123 sends a 301 Moved Permanently to http://www.last.fm/test123.

var express = require('express'),
    httpProxy = require('http-proxy');

// proxy server
var lastfmProxy = httpProxy.createServer(80, 'ws.audioscrobbler.com');

// target server
var app = express.createServer();
app.configure(function() {
  app.use('/_api', lastfmProxy);
});
app.listen(8000);

At the same time $ curl http://ws.audioscrobbler.com/test123 returns a regular 404 Not Found. I’m not exactly sure what I’m missing here, or if I’m approaching this completely the wrong way.

  • 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-26T07:03:34+00:00Added an answer on May 26, 2026 at 7:03 am

    The reason you get a 301 Moved Permanently is that ws.audioscrobbler.com gets an HTTP request with the hostname “localhost”.

    One solution is to let the proxy rewrite the hostname to “ws.audioscrobbler.com” before passing it on to the remote server:

    var httpProxy = require('http-proxy');
    
    var lastfmProxy = httpProxy.createServer(function (req, res, proxy) {
      req.headers.host = 'ws.audioscrobbler.com';
      proxy.proxyRequest(req, res, {
        host: 'ws.audioscrobbler.com',
        port: 80,
      });
    }).listen(8000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Node.js to create a zip file from an existing folder,
I'm trying to use quoted text in one of node's attributes: var network_json =
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to set up multi node Cassandra cluster in a local network. I
I'm trying to set up a simple project using Node.js and Express with Expresso
I am trying to figure out how to use mongoose-joins for Node.js. I have
I'm trying to use the example that comes in the slony tutorial but it
Problem: I am having trouble generating an xpath expression that selects a node in
I'm trying to use STL to solve the following problem (I don't want to

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.