Firebase Hosting - How to redirect domain to url (.pl to .com/pl) - firebase-hosting

I'm using Firebase Hosting. I own two domains:
mydomain.com and mydomain.pl (polish version)
I would like to redirect mydomain.pl to mydomain.com/pl (this is how I manage website translations).
In Firebase Hosting configuration I can only redirect mydomain.pl to mydomain.com. If I enter mydomain.com/pl error message is shown: "Enter a valid domain (not a URL)".
Website is served using https.

Instead of redirecting with firebase hosting, create an index.html file for yourdomain.pl and then use javascript to redirect. You don't need any content at all in the index.html file just your redirect. You can use this code:
<script>
window.location = "https://yourdomain.com/pl";
<script>
Let me know if you need any help.

Related

Firebase Hosting - "Site not Found" when loading page with "www." prefix

I'm currently working on deploying a site on firebase hosting, I want both domains:
charrocel.com & www.charrocel.com
To load my website.
The problem I'm facing is that when I try to enter with www. prefix, I get the following error:
This is how custom domain looks on firebase hosting:
And this is how I have my DNS setup:
I've tried to point 'www' with an "A" record pointing the firebase IP but nothing. On firebase hosting, I've also tried to setup the www.charrocel.com site as a separate domain but nothing.
Please, any help will be kindly appreciated.
The problem may have been a configuration delay on the Firebase backend or a stale cache in your browser.
From my computer the https://www.charrocel.com URL correctly redirects to charrocel.com and the website looks OK.
Your problem is probably not caused by DNS because your www.charrocel.com screenshot shows an error message generated by Firebase servers. DNS resolution worked.
If the problem persist on your side try checking the URL from an "incognito mode" / "private browsing" window.

Nuxt & Strapi - Logging in with OAuth using Github

I am setting up a community website with a Strapi CMS backend and a NuxtJS frontend using the composition API.
Besides the normal registration and login using email and username (which works!), I want users to be able to login using GitHub.
I am using #nuxtjs/auth module for authorization.
I've "deployed" my Strapi backend using ngrok. This is needed apparently to make OAuth work.
I've set up my GitHub application, using <ngrok-url>/connect/github/callback as the callback.
I've set the GitHub client_id and secret in my .env file.
In the strategies in my nuxt.config.js file I have this:
github: {
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
},
I've added a line in config/server.js of the Strapi backend:
url: '<ngrok url>'
So the backend is fired up in that location.
In my Strapi configuration, I've enabled a GitHub provider, and I need a redirect url to my frontend there. I am not sure what to put here.
I've tried: http://localhost:3000 (my Nuxt app port), but then I get a redirect uri mismatch error ("the redirect uri must match the registered callback"), when I try to access it from the frontend (using nuxt-auth's loginWith('github)').
More info on this here, but I don't get what they are saying.
Provide a redirect_uri where?
And they say to have a redirect_uri that matches what you registered. That matches what exactly?
The nuxt-auth docs are not that elaborate, saying to use $auth.loginWith('github') and that's it. I do this in my frontend, but I'm not sure if that is all I should do.
I can go manually to "<ngrok-url>/connect/github" (in ingognito) and login there in GitHub and I get redirected to the url I put in Strapi, with the access token as a parameter. So that part seems to work.
My main 2 question are:
How do I make the correct call from the frontend to the right endpoint to login through GitHub?
How do I process the result of that call?
Any help is much appreciated!
Update #1
I added a property redirectUrl on the github strategy in nuxt.config.js with the <ngrok-url>/connect/github/callback. That fixes a redirecting issue from GitHub.
I also added a redirect in Strapi to localhost:3000/connect/github and added a page in nuxt following this solution.
Now, I get back a jwt token and a user from Strapi, but $auth.loggedIn is still false in my front end. I'll try to fix this by writing my own middleware. I think this is needed because the app is server-side rendered.
The issue was that loginWith('github') connects nuxt directly to github. But we want to go to Strapi first. So in the end, I removed all the github-related info in my frontend and made a regular <a> with href to <strapi-url>/connect/github and then handled the response in a vue page like so:
data() {
return {
provider: this.$route.params.provider,
access_token: this.$route.query.access_token,
}
},
async mounted() {
const res = await this.$axios.$get(
`/auth/github/callback?access_token=${this.access_token}`,
)
const { jwt, user } = res
await this.$auth.setUserToken(jwt)
this.$auth.setUser(user)
this.$router.push(`/`)
},
To test it locally, I used ngrok to fire up the backend in a tunnel, instead of localhost.
If you want to look at more code, check out my PR here

Google search showing up the Amazon S3 website link

This is how I set up redirection to the Amazon S3 site:
(Basically followed instructions from here)
Set up a bucket called www.mysite.com and configured it for static website hosting
In my Godaddy account, configured:
Added a CNAME entry for 'www' to point to the publicly accessible S3 site (like mysite.in.s3-website.amazonaws.com)
Added a forwarding rule (302 redirect) to make both mysite.com and www.mysite.com work - whenever someone types in mysite.com, it redirects (browser url bar changes) to www.mysite.com.
Coming to my actual problem - when I do a Google search, the pages are listed under the S3 site ( mysite.in.s3-website.amazonaws.com) - which I'd like to think of as an implementation detail. Is there something else I should do to get google recognize and show links under mysite.com ?

Meteor - Facebook authorization simply isn't working

I'm running a meteor app from a server at http://example.com:3000 and trying to get it to authorize via Facebook using accounts-facebook.
My HTML looks like this:
<head>
<title>appname</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
<template name="hello">
<button>Click Me</button>
{{>loginButtons}}
{{#if currentUser}}
Logged in
{{/if}}
</template>
I do have accounts-ui and accounts-facebook enabled. I went through the Facebook app registration process. Here are my basic settings:
My advanced settings are default, and I have switched the "Do you want to make this app and all its live features available to the general public?" on in Status & Review.
When I actually try to log on using Facebook, the authorization window redirects to http://localhost:3000/_oauth/facebook?code=AQBaOoQ8XVQvzdqH8dyF03vVVP3daO9UO-tB0IZYCsYOYxL0LFWVrZUt2Rh34I2HI8Y5kofDP8sj46dn--N1pk6h0WOfoLAoaZxJzwSjocmBrRowjGv8JWcyN42msFuUdQAxQzbyrhnE2mQFUQISBOVzbnsR20ozS1pUmSdCb9BbmbidS8NvKvtEmSXm1lh9zPH7DYG4KfWQ2yIWSO8JMLEWa04TOP5rLDc75ak4WfXr1emb25T7981HUL8pCF_d_NgbFCNojoyY2yIB80e1nHxhovr-V3UWcCrNjH8aljTxy-qVGCmuLa4GravNIRfy9I8&state=eyJsb2dpblN0eWxlIjoicG9wdXAiLCJjcmVkZW50aWFsVG9rZW4iOiJlUkpSQjRja0FqVmJTWklCajhvQ01IdGlVdkktNnBXcF81d0RGR3Rod1lDIn0%3D#_=_, which isn't a valid address as the server is run and accessed remotely.
Additionally (and I suppose most problematically), the page doesn't acknowledge that any authorization has occurred, and acts like the login has failed (so I assume it has).
Can anyone tell me what I'm doing wrong? Thanks!
To make Meteor try to redirect from the Facebook login to the correct landing page (hosted at example.com, not localhost), I needed to make Meteor acknowledge that it's being run on example.com, not localhost:3000. The way to do this was to set the environment variable ROOT_URL.
On bash:
export ROOT_URL=http://example.com:3000
If you're running the site on example.com on port 3000, be sure to put it in your .profile or equivalent to make the environment variable persist between sessions.
Check the redirect URI on the "Advanced" tab.
It should be like this:http://localhost:3000/_oauth/facebook
NOT like this: http://localhost:3000/_oauth/facebook?close
Lets try this.
First go through
My apps > Test apps
Now on the top-right there is a Green button create a test app
Now some kind of modal appears, Test App Name and Test App Namespace, select whatever name you want
First
on Basic complete this 2 options
Now on App Domains select
localhost:3000
and on the site URL.
localhost:3000
and on advanced, on the Valid OAuth redirect URIs
http://localhost:3000/sessions/create
Second
on the /server/facebook-config.js for example, add this code.
// first, remove configuration entry in case service is already configured
Accounts.loginServiceConfiguration.remove({
service: "facebook"
});
Accounts.loginServiceConfiguration.insert({
service: "facebook",
appId: "yourTestAppId",
secret: "yourTesSecret"
});
And it should work
#RiverTam's answer did it for me! I have self-signed SSL cert on localhost with SSLProxy and I was under the wrong assumption that you could add custom routes to the callback URL, so I had to do several things:
1. In the meteor run command, export ROOT_URL first before meteor run
export ROOT_URL=https://localhost:3100; meteor --settings settings-development.json --port 3100
2. Add the callback url that FB wants, with localhost domain
Navigate to FB App in developer.facebook.com => Facebook Login => Settings => Client OAuth Settings and add URL like so:
3. Leave Domain empty
This is under FB App in developer.facebook.com => Settings => Advanced => Domain Manager
+999999 to River Tam for FireFly reference :P

facebook app: cross domain error although it seems well set-up

I have a web app that runs on localhost or example.com. And I am loading the facebook apps sdk to be able to do Single Sign-On, but I have this error in the console:
XMLHttpRequest cannot load https://www.facebook.com/impression.php. No 'Access-Control-
Allow-Origin' header is present on the requested resource. Origin
'http://example.com' is therefore not allowed access.
whereas I have gone in the settings of the facebook app and enter http://localhost/ or http://example.com/ in the Site URL field.
Here's the screen capture of my local url for instance :
...and the corresponding setting my facebook app account :
I really need some help here please !
Url given in SITE URL field must be match with your WEB URL [where facebook sdk invoked.]
Hence in your case, SITE URL field given : www.example.com
Web App URL must be : www.example.com
I'm running it locally under IIS Express using
http://localhost:XXXXX/
where XXXXX is the port number the website is running on and that works for me.