sails redirecting to https on localhost - sails.js

I have one live project, which I run on my localhost for development. As the live site is on HTTPS. So, after cloning on local, I comment https code. But still, when I open http://localhost:1337 it redirects me to https://localhost:1337 due to which it's not working on localhost. Even sails lift output is showing HTTP URL on the console.
sails lift output

Related

Get content from local server when accessing a custom local url (http://localost:8080 from http://localhost/testing)

I apologize if i'm being vague, but i don't know how to ask in more technical terms.
I have a server running on my local machine on a random (known) port. I started it with python -m SimpleHTTPServer 8080. I want to be able to type http://localhost/testing or any url (if the solution is simpler) and get that content that's served on the above mentioned port. The url i'm accessing needs to be <something/somethingelse> (have a slash in there). Reason being, i'm doing some url manipulation and need to test different scenarios.
ex: server is serving content on http://localhost:8080 - i want to type http://localhost/testing in the browser url and get whatever's served on localhost:8080.
I couldn't do it with hosts mapping. I'm on a mac.
The question would be much clearer if you used complete URLs. I'm guessing what you're asking for is a redirect or a proxy:
From http://localhost/testing
To: http://localhost:8080
The solution would be to install a web server (separate from the python SimpleHTTPServer) that is configured to listen on port 80 and redirect based on URL path, e.g.
if URL path == /testing,
then redirect to http://localhost:8080
Depending on your platform, you might use nginx (linux/macos) or IIS (windows). You might even be able to use nginx on Windows if you're using WSL. Instructions for installing and configuring those packages.
Configuring a simple redirect is far easier than a proxy.

Circumventing web security limitations between two sites on the same server

I'm using Eclipse to develop an app that consists of an Angular 2 front end and a Java REST back end.
For the front end, I'm using the Angular CLI plugin, which starts the app by issuing an ng serve command to the CLI. This command sets up an http server on port 4200.
For the back end, I'm using an in-company framework that launches in Jetty within Eclipse in port 8088.
While both these ports are configurable, by nature of the frameworks and plugins in use, they'll always be distinct.
Authentication works via an OAuth2 service that is also deployed to port 8088, as part of the framework. This service sets a cookie which certifies the browser session as authenticated. I have verified that this service works correctly by testing it against a Swagger instance of the REST API (also running in 8088 as part of the same framework).
The problem is that when the browser is aimed at the Angular 2 app on :4200, its internal REST API requests to :8088 aren't carrying the authentication cookie. Presumably, this is because of cross-site protection.
Is there any way for the app or the framework to tell the browser that these two "sites" are actually part of the same system?
Alternatively, if I have to configure the dev browser (Chrome) to work, I can live with that too. However, I've tried the --disable-web-security --user-data-dir recommendation, but the cookie still doesn't show up on the requests.
Lastly, I have Apache installed on the dev machine. If I can set up appropriate vhosts and use it as a proxy so that the browser thinks it's all the same, that would probably work too. It would just be a matter of intercepting all /swagger and /api requests and sending them to :8088, and all forwarding all other requests to :4200. However, I've been banging my head against mod_rewrite and mod_proxy and haven't been able to come up with anything that works.
I think what you're looking for is
withCredentials = true
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials

The redirect_uri URL is not supported

I am using facebook app on two servers, dev and live. The dev server is hosted at test.testdev.com and live server is hosted at test.testlive.net. Earlier it was working properly on both the servers but now it works only on dev.
When I try to access it on live server it displays the following error:
redirect_uri URL is not supported
My Facebook app is configured as follows:
Site URL: http://testlive.net/
App Domains: testlive.net testdev.com
I tried using different settings but it didn't worked for me. What may be reason behind this? Also should the redirect_uri start with http/https ?
I found the answer to my question. For live server the redirect_uri was not configured properly i.e. redirect_uri was //test.testlive.net whereas it should have been started with http/https like http://test.testlive.net.
So in future if you face this issue make sure your redirect_uri should start with http or https

Facebook Login API not working on localhost

I am able to interact with the Facebook Login API from my hosted web server, however when I change these settings to the localhost server I receive the message below. I have also tried adding a port number (80) but with no success. I have researched this question here on SO but it seems that I am missing something.
App Domains: localhost
Site URL: http://localhost/
Erorr: Given URL is not allowed by the Application configuration....
Add the port you are using at your localhost and you will get, you are looking for ....
like http://localhost:62024/

Meteor ROOT_URL setting to make accounts-facebook work when behind apache proxy

I'm running meteor on localhost:3000 and I have apache set up to proxy requests for a domain to that meteor instance using a virtualhost and mod_proxy.
I'm getting this error when trying to log in to my meteor app using accounts-facebook:
Given URL is not allowed by the Application configuration.: One or
more of the given URLs is not allowed by the App's settings. It must
match the Website URL or Canvas URL, or the domain must be a subdomain
of one of the App's domains.
I think this is because my ROOT_URL is http://localhost:3000 . If I change the ROOT_URL to the domain, then of course meteor tries to listen to the domain, but can't because my apache server is in the way.
Is there a way I can make this work without another IP address?
From Meteor documentation,
Ensure that your $ROOT_URL matches the authorized domain and callback
URL that you configure with the external service (for instance, if you
are running Meteor behind a proxy server, $ROOT_URL should be the
externally-accessible URL, not the URL inside your proxy).
In my case, my app is listening on a configured port with mod_proxy behind an Apache proxy server, say it is listening http://www.example.com:8080. I have other applications running on other ports.
To get going, on Facebook I set Site URL and Valid OAuth redirect URIs to http://www.example.com:3000 and App Domains to www.example.com. On my machine I set ROOT_URL to http://www.example.com:3000, which is externally-accessible.
Such configurations work for me without a second IP address.
I could get it working by simply having
# /etc/hosts
127.0.0.1 localhost.localdomain localhost
And the facebook settings as in the image below. I've set a secondary (mobile) url to point to http://localhost:3000
I've created a whole facebook app like this, with login, access to graph-api etc. And everything was working both online and in the dev envrionment