next.js with firebase hosting: how to create the 404.html file for firebase? - firebase-hosting

I am using next.js with Static HTML export, and i want to use firebase for hosting.
The problem is that firebase require a page in the root called 404.html for unknown routes.
Is there a way to generate such page using next.js? or maybe change the firebase hosting behavior?

Actually i found a solution, i added to the firebase.json a rewrite to the error page:
"rewrites": [
{
"source": "**",
"destination": "/_error/index.html"
}
]
now, only if the page is not found, firebase will serve the error page as explained here:
https://firebase.google.com/docs/hosting/url-redirects-rewrites

Related

Parse Arguments from URL for Flutter Web App

My Use Case:
Users in my app can create lists of items. I want the users to be able to share a link to one of their lists.
I want individuals who click the shared link to see the list of items in a web browser and not need the app installed.
I originally thought Dynamic linking was what I was looking for. But as I have done more research I don't think I need dynamic linking to just read info from a link and the navigate to the right view in the web app.
My Attempt: onGenerateRoute
Doing some research I stumbled onto this Stack Overflow Question: How can a named route have URL parameters in flutter web?
After reading that I tried this in my own code:
routes: appRoutes,
onGenerateRoute: (settings) {
if (settings.name == "/pack") {
//in your example: settings.name = "/post?id=123"
final settingsUri = Uri.parse(settings.name!);
//settingsUri.queryParameters is a map of all the query keys and values
final postID = settingsUri.queryParameters['id'];
print(postID);
Navigator.pushNamed(context, '/home');
}
},
I wanted to see if I could just print the id passed in https://myApp.app/pack?id=100
Unfortunately, I can't even get to that point to test my code above. I depleted my web app to my domain and if I go to any address other than https://myApp.app then I get a 404 error. Anything after the main URL like https://myApp.app/anything will go to a 404.
I have a hunch I need to edit my firebase.json. Right now it's set up for dynamic linking with /p but not sure what I need to fix here or someplace else to have the above code execute and not route to a 404 error page.
firebase.json
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/p/**",
"dynamicLinks": true
}
]
}
}

firebase dynamic links in stripe throws err_unknown_url_scheme

I've been developing an app with firebase and stripe payment. I've created a checkout session in stripe and added firebase dynamic links for the success_url and cancel_url. The URLs are working fine. I've tested them outside stripe with a simple html file and it opens the app and takes the user to the correct page. If the page doesn't exist it'll take the user to the assigned website. This is stripe checkout session code:
const session = await stripe.checkout.sessions.create({
line_items: [{
price_data: { currency: 'INR', unit_amount: amount, product_data: { name: 'name' } },
quantity: 1,
}],
mode: 'payment',
success_url: 'https://-------.page.link/payment-success',
cancel_url: 'https://-------.page.link/payment-failed',
payment_intent_data: {
application_fee_amount: fee
},
}, {
stripeAccount: req.query.stripeId,
});
I've changed up the actual link since I don't know how much I'm allowed to share. But I can guarantee the dynamic links works fine. But after payment, the test payment at least, it's suppose to open the app and take the user to a payment success page. AND it was working fine for the first 2 or 3 days. After payment it re-opened the app and took the user to the correct page. But when I tried a few days later, this is what it's taking us to:
Again, I've removed the link since I don't know how much I'm allowed to share. It won't even open the app right now. It just shows this message in the browser. Both success and cancel url are doing the same. Why does the links work outside the function but not in it? Has anyone ever faced any similar issues before? Any help will be greatly appreciated.
It seems like you're trying to open the Checkout Session in a WebView which causing the issue in the redirect. Webviews don't know how to handle an URL Scheme other than http:// or https://. That being said, your problem isn't uncommon and there are multiple ways of solving this.
Your first approach would be to open the Checkout Session in an external browser as described in this answer or try to create your own WebViewClient and override shouldOverrideUrlLoading method like described in this answer. Just note that since the last edit of that answer the signature of the shouldOverrideUrlLoading method has changed but the logic should still be used the same way but instead of dealing with the String url, you will have to deal with a WebResourceRequest.
Had the same issue. I solved it by changing the mode like following:
await launchUrl(
url,
mode: LaunchMode.externalApplication, // Add this line
)
url_launcher version => 6.1.7

Firebase hosting do not rewrite and go on index

I created a website in Flutter and I got only two pages in my website. A HomePage and a DetailPage.
Currently, the HomePage is working well with the rule :
{
"source": "/**",
"destination": "/index.html"
}
I want to have the DetailPage working with the URL /item/:idItem
The problem is if I do something dumb like that :
{
"source": "/item/:idItem",
"destination": "/item/:idItem"
}
I'm on a 404 Page Not Found from Firebase. I need to point on the HomePage, with the custom URL because it's my HomePage that is retrieving URL and choosing if I show the Home or the Details.

Incorrect mapping URL of SAPUI5 app on Fiori Launchpad

I have two SAPUI5 apps and they both are working well, but there is a problem with them on Fiori launchpad. The initially opened app gets the correct url to our rest service (.json), but after I click the Home button and go to the second app the url gets put together incorrectly, because the resource-path of the second App still contains the folder of the initial App.
1. .../app1folder/app1resource
2. .../app1folder/app2resource
Correct would be:
2. .../app2folder/app2resource
The resources we use are created as destinations in the SAP HANA Cloud Platform Cockpit>Connectivity>Destinations
Neo-app.json
{
"path": "/app1resource",
"target": {
"type": "destination",
"name": "app1"
},
"description": "app1 API"
}
How can I manually change the "appfolder"-directory (app1folder, app2folder)? Or is it automatically created by the fiori launchpad and unaccessible?
My application is built from scratch and not generated and maybe there's a common mistake.
Thank you.
Problem:
Both apps had the same id and as a result the launchpad couldn't load the applicationfiles into the scope.
Solution:
I changed the app id and all related references in the controllers, modules... .

Grails social plugins for facebook give error response after user authenticate application

I am new to grails and i am trying to add facebook plugin to my web application. i have successfully(as i believe) installed plugins and addED necessary code in my application. I followed the documentation found at http://splix.github.io/grails-spring-security-facebook/ , when I run my app I see the facebook connect button on gsp page,after clicking on connect button a popup opens up asking for permissions required in app and when user clicks on allow button i receive error "No authentication provider found". I dont know where i am wrong ,can any one help me please.
Thanks in advance
You have custom list of providers:
grails.plugins.springsecurity.providerNames = [ 'myAuthenticationProvider',
'anonymousAuthenticationProvider',
'rememberMeAuthenticationProvider']
And none of them supports FacebookAuthToke, so Spring Security cannot authenticate using Facebook Authentication plugin.
If you really need to have custom provider, just put original provider into this list:
grails.plugins.springsecurity.providerNames = [ 'myAuthenticationProvider',
'facebookAuthProvider',
'anonymousAuthenticationProvider',
'rememberMeAuthenticationProvider']