Flutter website on firebase hosting works fine with domain 1 but not domain 2 - firebase-hosting

I am using flutter web to create a website for my buisness. I am hosting it on firebase hosting with the url
https://xspectre-9a3b3.web.app/
Now when I added the new domain
https://xspectre.net
The website does not load in this domain and gives the error
main.dart.js:1 Uncaught SyntaxError: Unexpected token '<'
(index):1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://xspectre.net/') with script ('https://xspectre.net/flutter_service_worker.js'): The script has an unsupported MIME type ('text/html').
It does not work with https://xspectre-9a3b3.firebaseapp.com/ either. What should I do?
EDIT
I discovered the real error is not the MIME type one since it is in my real project too. The actual error is somehow
Uncaught SyntaxError: Unexpected token '<'
When I open the main.dart.js it shows me different code then it should. It shows me the html files not the main.dart.js code and I think that is what is causing the problem. I dont know how or why the files are different for both the URLs.
**EDIT 2 **
Finally figured out the root problem.
Whenever I try to do firebase init, it goes to initialize the whole flutter directory. This means that it says,
You're about to initialize a Firebase project in this directory:
C:\FlutterProjects\xspectre
and not
You're about to initialize a Firebase project in this directory:
C:\FlutterProjects\xspectre\build
Now I need to figure out how to do firebase init and deloy in the /build and not root

The website probably still works for you as it is already cached by the service worker. Try with another browser and it will not work.
firebase init should be run in the project directory, not in the build directory.
After that, edit your firebase.json file to look like
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache"
}
]
}
]
}
}
"public": "build/web" points to the directory where the files for deployment are.
Now you can do flutter build web and firebase deploy

Related

how to configure the bundle extension in Firebase on Flutter project

I am currently trying to build the pipeline for serving a bundle of data in my project and I can't make it work even by reading the step by step documentation that firebase gives us.
I have followed the documentation and was able to create a bundle through this documentation:
https://firebase.google.com/docs/extensions/official/firestore-bundle-builder
But when I get to the documentation on building and serving the bundle, things start to falling apart since I cannot find complete resources explaining how to implement it
So that is how I implemented it:
{
"functions": [
{
something
"ignore": [
something
],
something
]
}
],
"hosting": {
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/bundles/*",
"function": "ext-firestore-bundle-builder-serve"
}
]
}
}
Is it in the right level or not ? No idea... but that's what I did and I deployed it successfully.
Now, in the client integration part:
import { loadBundle } from "firebase/firestore";
// Download the bundle from the Firebase Hosting CDN:
const bundle = await fetch("/bundles/:bundleId");
// If not using a CDN, download the bundle directly:
// const bundle = await fetch('https://<location>-<project-id>.cloudfunctions.net/ext-firestore-bundle-builder-serve/:bundleId');
await loadBundle(bundle);
I do not know again how to implement it since the import give me an error, and every functions too.
I'd appreciate your help.
I am not new with firebase and I am not that bad at finding the documentation in order to understand but I don't know if the SEO is not good or the documentation not complete and will be completed but I failed to find it..
Thanks for your time

firebase emulator localhost 500 showing error after updating firebase to latest version

after updating to 'Windows 11, version 22H2' and firebase, Local server: http://localhost:5000 is not working showing error 'Cannot GET /' cannot point out what went wrong
happening with all my older peojects also
need to add
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
in firebase.json
under hosting

Unable to Access SAP Fiori Application - Error: 403 Forbidden

I have been trying out the Freestyle SAP Fiori Project and Deployed it to my Sub Account Space. It is Deployed Successfully and it is in a running state. However, when I try to access it, it says "403 Forbidden".
Screenshot 1: Error Message while Accessing the App
Screenshot 2: App Status
#Update 1: Roles, Scope, Role Templates are Empty
I went inside the deployed Application to see its Roles, Scopes & Role Templates. But all of them are empty. Can this be the reason? If yes, how do we assign them?
#Update 2: Roles, Scope, Role Templates are Empty
I have verified the MTAR Archive to see whether xs-security.json file is getting included and I can confirm it is getting included. For example, below is the content of that file.
xs-security.json
{
"xsappname": "demofiori",
"tenant-mode": "dedicated",
"description": "Security profile of called application",
"scopes": [
{
"name": "uaa.user",
"description": "UAA"
}
],
"role-templates": [
{
"name": "Token_Exchange",
"description": "UAA",
"scope-references": [
"uaa.user"
]
}
]
}

cordova run android takes "wrong" database

Hello fellow ionic developer,
I use visual studio code (VSC) to develop an ionic 4 application.
Situation:
Usually I emulate an API 19 Android Phone but this has to be builded everytime ionic cordova run android and I can not get it running with the -livereload flag (this takes a lot of time for even little changes). That is when I tried run the app with the cordova plugin for VSC to get a live emulator for debugging and working on my app.
Problemcontext:
I added a database for local storage of patient information. Therefore, I added a seed which provides some patient data and a user. The userlogin works like a charm, during the login I immediatly load all patients for the user. And this is were the problem is:
Apparently, the underlying database / seed is in some old state since I just changed the user values and I can not login with the new seed values.
Unhandled Promise rejection: a statement error callback did not return false: Failed to import SQL; message=sqlite3_prepare_v2 failure: table patient has 14 columns but 27 values were supplied
This is the error that brought me here.
So my question is:
Is there an opportunity to rake/prebuild/... the seed file or where is the seed file located (for using the VSC emulator, since it works on the android studio emulator but also not on the physical device) for the emulator so I can delete or redesign it.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Android on emulator",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "emulator",
"port": 8100,
"sourceMaps": true,
"cwd": "${workspaceFolder}",
"ionicLiveReload": true
}
]
}
Thank you in advance
I found a workaround:
//DELETE FOR DEPLOY
this.deleteDatabase("databasename.db");
deleteDatabase(databasename: string)
{
try{
this.sqlite.deleteDatabase(
{
name: databasename,
location: 'default'
}
)
}
catch(error){
console.error(error)
}
}
You should delete the current database and just populate the database again with the new seed.sql
From: https://stackoverflow.com/questions/52033237/how-to-delete-sqlite-database-in-ionic3

Permission error when trying to use chrome.fileSystem chooseEntry

When trying to use
chrome.fileSystem.chooseEntry({
type: 'openFile'
},chooseEntryCallback)`
on Canary 28.0.1483.0 , I get the following error in the console:
chrome.fileSystem is not available: You do not have permission to access this API. Ensure that the required permission or manifest property is included in your manifest.json.
I only require read access, and this is how my permissions option in the manifest file looks like:
"permissions": [
{
"fileSystem": []
},
"contextMenus",
"clipboardWrite",
"storage"
],
This works fine with Stable 26.0.1410.64 so the question is whether there are some manifest permission changes which will need to be updated.
Note: Chrome running on Windows 8, and when opening the file via drag 'n drop it is opened without errors. So i'm guessing its some problem with chooseEntry ?
Based on #sowbug's comment I fixed this issue by changing the fileSystem permission to a list item:
"permissions": [
"fileSystem"
],
Edit:
To include the extended write permission:
"permissions": [
"fileSystem",
"fileSystem.write"
],