Skip to content

Commit

Permalink
fix: fix proxy paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Mar 19, 2018
1 parent 27c5879 commit 92b3dc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as functions from 'firebase-functions';
import * as httpProxy from 'http-proxy';

const app = express();
const proxyRouter = express.Router();

const proxy = httpProxy
.createProxyServer({
Expand All @@ -21,16 +22,18 @@ proxy.on('proxyRes', function(proxyRes, req, res) {
}
});

app.get('/1.1/statuses/user_timeline.json', function(req, res) {
proxyRouter.get('/1.1/statuses/user_timeline.json', function(req, res) {
if (req.query.screen_name === 'realDonaldTrump') {
proxy.web(req, res);
} else {
res.sendStatus(403);
}
});

app.get('/1.1/statuses/show.json', function(req, res) {
proxyRouter.get('/1.1/statuses/show.json', function(req, res) {
proxy.web(req, res);
});

app.use('/api', proxyRouter);

export const api = functions.https.onRequest(app);
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
apiHost: 'http://localhost:5000/trumpymctweetface/us-central1/api',
apiHost: 'http://localhost:5000/trumpymctweetface/us-central1/api/api',
production: false,
};

0 comments on commit 92b3dc2

Please sign in to comment.