Popular New Releases in Email
PHPMailer
PHPMailer 6.6.0
mjml
v4.12.0
Mailspring
1.10.3
postal
2.1.1
mailinabox
Popular Libraries in Email
by PHPMailer php
18018 LGPL-2.1
The classic email sending library for PHP
by nodemailer javascript
14094 NOASSERTION
✉️ Send e-mails with Node.JS – easy as cake!
by mjmlio javascript
13299 MIT
MJML: the only framework that makes responsive-email easy
by Foundry376 c
12529 GPL-3.0
:love_letter: A beautiful, fast and fully open source mail client for Mac, Windows and Linux.
by postalserver ruby
11501 MIT
✉️ A fully featured open source mail delivery platform for incoming & outgoing e-mail
by mail-in-a-box python
10720 CC0-1.0
Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
by egulias php
10608 MIT
PHP Email address validator
by postalhq ruby
10570 MIT
📨 A fully featured open source mail delivery platform for incoming & outgoing e-mail
by leemunroe html
10511 MIT
A free simple responsive HTML email template
Trending New libraries in Email
by sdushantha shell
2789 MIT
A temporary email right from your terminal written in POSIX sh
by soywod rust
1718 BSD-4-Clause
Command-line interface for email management
by djyde typescript
1494 GPL-3.0
lightweight, privacy-friendly alternative to Disqus.
by mettle php
860 MIT
Open-source self-hosted email marketing. Manage your own newsletters at a fraction of the cost.
by Rog3rSm1th python
855 MIT
OSINT tool that allows you to find a person's accounts and emails + breached emails 🕵️
by andris9 javascript
854 AGPL-3.0
Self hosted application to access IMAP and SMTP accounts over REST
by geongeorge javascript
578 MIT
Switch git user and email at ease
by AfterShip go
364 MIT
:white_check_mark: A Go library for email verification without sending any emails.
by s0md3v python
299 GPL-3.0
Generate Email, Register for anything, Get the OTP/Link
Top Authors in Email
1
20 Libraries
2466
2
16 Libraries
8136
3
14 Libraries
590
4
13 Libraries
981
5
13 Libraries
708
6
13 Libraries
4491
7
11 Libraries
118
8
10 Libraries
1970
9
9 Libraries
14664
10
8 Libraries
988
1
20 Libraries
2466
2
16 Libraries
8136
3
14 Libraries
590
4
13 Libraries
981
5
13 Libraries
708
6
13 Libraries
4491
7
11 Libraries
118
8
10 Libraries
1970
9
9 Libraries
14664
10
8 Libraries
988
Trending Kits in Email
Trending Discussions on Email
Selenium-chromedriver: Cannot construct KeyEvent from non-typeable key
Action requested: Declare your Ad ID permission
Test functions cannot both take a 'done' callback
Why @FocusState Crashing SwiftUI Preview
How do I fix a Firebase 9.0 import error? "Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase')."
FirebaseOptions cannot be null when creating the default app
Activiti 6.0.0 UI app / in-memory H2 database in tomcat9 / java version "9.0.1"
I worked on a private repo in GitHub then made it public. Can I make my activity visible?
How do I run multiple sites on the same server using docker and nginx?
Default route always execute in react router
QUESTION
Selenium-chromedriver: Cannot construct KeyEvent from non-typeable key
Asked 2022-Mar-25 at 12:17I updated my Chrome and Chromedriver to the latest version yesterday, and since then I get the following error messages when running my Cucumber features:
1....
2unknown error: Cannot construct KeyEvent from non-typeable key
3 (Session info: chrome=98.0.4758.80) (Selenium::WebDriver::Error::UnknownError)
4 #0 0x55e9ce6a4093 <unknown>
5 #1 0x55e9ce16a648 <unknown>
6 #2 0x55e9ce1a9866 <unknown>
7 #3 0x55e9ce1cbd29 <unknown>
8 .....
9
I try to fill a text field with Capybara's fill_in
method. While debugging I noticed that Capybara has problems especially with the symbols @
and \
. Every other character can be written into the text field without any problems.
The code that triggers the error looks like this
1....
2unknown error: Cannot construct KeyEvent from non-typeable key
3 (Session info: chrome=98.0.4758.80) (Selenium::WebDriver::Error::UnknownError)
4 #0 0x55e9ce6a4093 <unknown>
5 #1 0x55e9ce16a648 <unknown>
6 #2 0x55e9ce1a9866 <unknown>
7 #3 0x55e9ce1cbd29 <unknown>
8 .....
9def sign_in(user)
10 visit new_sign_in_path
11 fill_in 'Email', with: user.email
12 fill_in 'Password', with: user.password
13 click_button 'Sign in'
14end
15
user.email
contains a string like "example1@mail.com"
.
I work with Rails 6.1.3.1, Cucumber 5.3.0, Chromedriver 98.0.4758.48, capybara 3.35.3
The error only occurs on features that are tagged with @javascript
Do you have any ideas what causes this error or how to fix it?
ANSWER
Answered 2022-Feb-03 at 08:25It seems something has changed in the new version of ChromeDriver and it is no longer possible to send some special chars directly using send_keys method.
In this link you will see how it is solved (in C#) --> Selenium - SendKeys("@") write an "à"
And regarding python implementation, check this out --> https://www.geeksforgeeks.org/special-keys-in-selenium-python/
Specifically, my implementation was (using MAC):
1....
2unknown error: Cannot construct KeyEvent from non-typeable key
3 (Session info: chrome=98.0.4758.80) (Selenium::WebDriver::Error::UnknownError)
4 #0 0x55e9ce6a4093 <unknown>
5 #1 0x55e9ce16a648 <unknown>
6 #2 0x55e9ce1a9866 <unknown>
7 #3 0x55e9ce1cbd29 <unknown>
8 .....
9def sign_in(user)
10 visit new_sign_in_path
11 fill_in 'Email', with: user.email
12 fill_in 'Password', with: user.password
13 click_button 'Sign in'
14end
15driver.find_element('.email-input', 'user@mail.com')
16
Now I had to change it by:
1....
2unknown error: Cannot construct KeyEvent from non-typeable key
3 (Session info: chrome=98.0.4758.80) (Selenium::WebDriver::Error::UnknownError)
4 #0 0x55e9ce6a4093 <unknown>
5 #1 0x55e9ce16a648 <unknown>
6 #2 0x55e9ce1a9866 <unknown>
7 #3 0x55e9ce1cbd29 <unknown>
8 .....
9def sign_in(user)
10 visit new_sign_in_path
11 fill_in 'Email', with: user.email
12 fill_in 'Password', with: user.password
13 click_button 'Sign in'
14end
15driver.find_element('.email-input', 'user@mail.com')
16from selenium.webdriver.common.keys import Keys
17from selenium.webdriver.common.action_chains import ActionChains
18
19emailParts = 'user@mail.com'.split('@')
20emailElement = driver.find_element('.email-input')
21
22emailElement.send_keys(emailParts[0])
23action = ActionChains(driver)
24action.key_down(Keys.ALT).send_keys('2').key_up(Keys.ALT).perform()
25emailElement.send_keys(emailParts[1])
26
QUESTION
Action requested: Declare your Ad ID permission
Asked 2022-Mar-15 at 13:37Today i have got this email:
Last July, we announced Advertising policy changes to help bolster security and privacy. We added new restrictions on identifiers used by apps that target children. When users choose to delete their advertising ID in order to opt out of personalization advertising, developers will receive a string of zeros instead of the identifier if they attempt to access the identifier. This behavior will extend to phones, tablets, and Android TV starting April 1, 2022. We also announced that you need to declare an AD_ID permission when you update your app targeting API level to 31 (Android 12). Today, we are sharing that we will give developers more time to ease the transition. We will require this permission declaration when your apps are able to target Android 13 instead of starting with Android 12.
Action Items If you use an advertising ID, you must declare the AD_ID Permission when your app targets Android 13 or above. Apps that don’t declare the permission will get a string of zeros. Note: You’ll be able to target Android 13 later this year. If your app uses an SDK that has declared the Ad ID permission, it will acquire the permission declaration through manifest merge. If your app’s target audience includes children, you must not transmit Android Advertising ID (AAID) from children or users of unknown age.
My app is not using the Advertising ID. Should i declare the AD_ID
Permission in Manifest or not?
ANSWER
Answered 2022-Mar-14 at 20:51Google describe here how to solve
https://support.google.com/googleplay/android-developer/answer/6048248?hl=en
Add in manifest
1<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
2
QUESTION
Test functions cannot both take a 'done' callback
Asked 2022-Mar-12 at 12:09I'm trying to create a simple test with nestjs, and I'm get this error
Test functions cannot both take a 'done' callback and return something. Either use a 'done' callback, or return a promise.
Returned value: Promise {}
The unit test is so simple, but I get an error when I use done();
1it('throws an error if user signs up with email that is in use', async (done) => {
2fakeUsersService.find = () => Promise.resolve([{ id: 1, email: 'a', password: '1' } as User]);
3try {
4 await service.signup('asdf@asdf.com', 'asdf');
5} catch (err) {
6 done();
7}
8});
9
ANSWER
Answered 2022-Jan-27 at 21:11You are combining Async/Await and Done.
Either use asnyc/await, or done.
1it('throws an error if user signs up with email that is in use', async (done) => {
2fakeUsersService.find = () => Promise.resolve([{ id: 1, email: 'a', password: '1' } as User]);
3try {
4 await service.signup('asdf@asdf.com', 'asdf');
5} catch (err) {
6 done();
7}
8});
9it('throws an error if user signs up with email that is in use', async () => {
10 try {
11 await service();
12 expect(...);
13 } catch (err) {
14 }
15});
16
or use the done format
1it('throws an error if user signs up with email that is in use', async (done) => {
2fakeUsersService.find = () => Promise.resolve([{ id: 1, email: 'a', password: '1' } as User]);
3try {
4 await service.signup('asdf@asdf.com', 'asdf');
5} catch (err) {
6 done();
7}
8});
9it('throws an error if user signs up with email that is in use', async () => {
10 try {
11 await service();
12 expect(...);
13 } catch (err) {
14 }
15});
16it('throws an error if user signs up with email that is in use', (done) => {
17 ...
18 service()
19 .then( ...) {}
20 .catch( ...) {}
21 }
22 done();
23});
24
QUESTION
Why @FocusState Crashing SwiftUI Preview
Asked 2022-Jan-26 at 19:02Okay, I wanted to know why my preview wasn't working after updating Xcode. So I have an enum that looks like this.
1enum Field {
2 case email
3 case securedPassword
4 case unsecuredPassword
5}
6
Now when I add @FocusState to my TestView my preview just crashes and doesn't update. Here is how my code looks like.
1enum Field {
2 case email
3 case securedPassword
4 case unsecuredPassword
5}
6struct TestView1: View {
7 @FocusState var focusedField: Field?
8
9 var body: some View {
10 Color.blue
11 }
12}
13
Now when I comment out the @FocusState I am able to change the color to something like red and the preview updates. When the @FocusState is not commented out, when I change the color to something new it doesn't update the preview and gives me a weird crash.
Now is this a bug and if so is there a work around?
ANSWER
Answered 2021-Dec-21 at 14:58Please see my related answer I posted a couple of months ago on the Apple Developer Forums located at: https://developers.apple.com/forums/thread/681571?answerId=690251022#690251022 . Does this work for you?
1enum Field {
2 case email
3 case securedPassword
4 case unsecuredPassword
5}
6struct TestView1: View {
7 @FocusState var focusedField: Field?
8
9 var body: some View {
10 Color.blue
11 }
12}
13struct TestView1: View {
14 enum Field: Hashable {
15 case email
16 case securedPassword
17 case unsecuredPassword
18 }
19
20 @FocusState var focusedField: Field?
21
22 var body: some View {
23 Form {
24 Color.blue
25 }
26 }
27}
28
29struct TestView1_Previews: PreviewProvider {
30 static var previews: some View {
31 // Here we've wrapped `TestView1` in a `ZStack { ... }` View
32 // so that it won't be the top-level View in our Preview, to avoid
33 // the known bug that causes the `@FocusState` property of a
34 // top-level View rendered inside of a Preview, to not work properly.
35 ZStack {
36 TestView1()
37 }
38 }
39}
40
QUESTION
How do I fix a Firebase 9.0 import error? "Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase')."
Asked 2022-Jan-02 at 09:35I am trying to implement firebase in my React application but it seems my version of importing is outdated. Here is my code:
1import firebase from "firebase/app";
2import "firebase/auth";
3
4const app = firebase.initializeApp({
5 apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
6 authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
7 projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
8 storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
9 messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
10 appId: process.env.REACT_APP_FIREBASE_APP_ID,
11});
12
13export const auth = app.auth();
14export default app;
15
I've replaced my config keys with process.env.REACT_APP_FIREBASE... as they are stored in another local .env file. I've also tried different ways of importing firebase, but it seems most posts are outdated. This is the error I am getting:
./src/firebase.js Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase').
I also have another file for authContext so I will need to keep the 'auth' keyword in my firebase.js file:
1import firebase from "firebase/app";
2import "firebase/auth";
3
4const app = firebase.initializeApp({
5 apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
6 authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
7 projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
8 storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
9 messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
10 appId: process.env.REACT_APP_FIREBASE_APP_ID,
11});
12
13export const auth = app.auth();
14export default app;
15import React, { useContext, useState, useEffect } from "react";
16import { auth } from "../firebase";
17
18const AuthContext = React.createContext();
19
20export function useAuth() {
21 return useContext(AuthContext);
22}
23
24const AuthProvider = ({ children }) => {
25 const [currentUser, setCurrentUser] = useState();
26
27 function signup(email, password) {
28 return auth.createUserWithEmailAndPassword(email, password);
29 }
30
31 useEffect(() => {
32 const unsubscribe = auth.onAuthStateChanged((user) => {
33 setCurrentUser(user);
34 });
35
36 return unsubscribe;
37 }, []);
38
39 const value = {
40 currentUser,
41 signup,
42 };
43 return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
44};
45
46export default AuthProvider;
47
ANSWER
Answered 2021-Aug-26 at 23:53Follow the instructions in the documentation, which specifically calls out the steps for version 9:
- Install Firebase using npm:
1import firebase from "firebase/app";
2import "firebase/auth";
3
4const app = firebase.initializeApp({
5 apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
6 authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
7 projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
8 storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
9 messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
10 appId: process.env.REACT_APP_FIREBASE_APP_ID,
11});
12
13export const auth = app.auth();
14export default app;
15import React, { useContext, useState, useEffect } from "react";
16import { auth } from "../firebase";
17
18const AuthContext = React.createContext();
19
20export function useAuth() {
21 return useContext(AuthContext);
22}
23
24const AuthProvider = ({ children }) => {
25 const [currentUser, setCurrentUser] = useState();
26
27 function signup(email, password) {
28 return auth.createUserWithEmailAndPassword(email, password);
29 }
30
31 useEffect(() => {
32 const unsubscribe = auth.onAuthStateChanged((user) => {
33 setCurrentUser(user);
34 });
35
36 return unsubscribe;
37 }, []);
38
39 const value = {
40 currentUser,
41 signup,
42 };
43 return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
44};
45
46export default AuthProvider;
47npm install firebase
48
- Initialize Firebase in your app and create a Firebase App object:
1import firebase from "firebase/app";
2import "firebase/auth";
3
4const app = firebase.initializeApp({
5 apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
6 authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
7 projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
8 storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
9 messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
10 appId: process.env.REACT_APP_FIREBASE_APP_ID,
11});
12
13export const auth = app.auth();
14export default app;
15import React, { useContext, useState, useEffect } from "react";
16import { auth } from "../firebase";
17
18const AuthContext = React.createContext();
19
20export function useAuth() {
21 return useContext(AuthContext);
22}
23
24const AuthProvider = ({ children }) => {
25 const [currentUser, setCurrentUser] = useState();
26
27 function signup(email, password) {
28 return auth.createUserWithEmailAndPassword(email, password);
29 }
30
31 useEffect(() => {
32 const unsubscribe = auth.onAuthStateChanged((user) => {
33 setCurrentUser(user);
34 });
35
36 return unsubscribe;
37 }, []);
38
39 const value = {
40 currentUser,
41 signup,
42 };
43 return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
44};
45
46export default AuthProvider;
47npm install firebase
48import { initializeApp } from 'firebase/app';
49
50// TODO: Replace the following with your app's Firebase project
51configuration const firebaseConfig = { //... };
52
53const app = initializeApp(firebaseConfig);
54
This is completely different than any method for any previous version of the Firebase SDKs. Note that you are importing individual functions from the Firebase SDK, not objects or namespaces.
To work with Firebase Auth, again follow the instructions in the documentation for v9:
1import firebase from "firebase/app";
2import "firebase/auth";
3
4const app = firebase.initializeApp({
5 apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
6 authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
7 projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
8 storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
9 messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
10 appId: process.env.REACT_APP_FIREBASE_APP_ID,
11});
12
13export const auth = app.auth();
14export default app;
15import React, { useContext, useState, useEffect } from "react";
16import { auth } from "../firebase";
17
18const AuthContext = React.createContext();
19
20export function useAuth() {
21 return useContext(AuthContext);
22}
23
24const AuthProvider = ({ children }) => {
25 const [currentUser, setCurrentUser] = useState();
26
27 function signup(email, password) {
28 return auth.createUserWithEmailAndPassword(email, password);
29 }
30
31 useEffect(() => {
32 const unsubscribe = auth.onAuthStateChanged((user) => {
33 setCurrentUser(user);
34 });
35
36 return unsubscribe;
37 }, []);
38
39 const value = {
40 currentUser,
41 signup,
42 };
43 return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
44};
45
46export default AuthProvider;
47npm install firebase
48import { initializeApp } from 'firebase/app';
49
50// TODO: Replace the following with your app's Firebase project
51configuration const firebaseConfig = { //... };
52
53const app = initializeApp(firebaseConfig);
54import { getAuth, createUserWithEmailAndPassword } from "firebase/auth";
55
56const auth = getAuth();
57
58createUserWithEmailAndPassword(auth, email, password);
59
Again note that you're importing functions to call directly, not objects with methods.
Compare to the old process with version 8: Upgrade to Firebase JS 8.0.0: Attempted import error: 'app' is not exported from 'firebase/app' (imported as 'firebase')
QUESTION
FirebaseOptions cannot be null when creating the default app
Asked 2021-Dec-25 at 09:13I am trying to try a sample project in Flutter integration email and google based login, and planning to use firebase initialisation for doing it while I have followed all the steps as mentioned in tutorials I am getting this error as soon as firebase is attempted to be initialised.
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16
Here is my index.html
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145
Part of code from main.dart file where firebase initialisation is happening
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150
Pubsec.yaml file of the project
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161 sdk: ">=2.15.0-268.18.beta <3.0.0"
162
163dependencies:
164 flutter:
165 sdk: flutter
166
167
168 # The following adds the Cupertino Icons font to your application.
169 # Use with the CupertinoIcons class for iOS style icons.
170 cupertino_icons: ^1.0.2
171 firebase_auth: ^3.3.0
172 firebase_core: ^1.10.2
173 google_sign_in: ^5.2.1
174 shared_preferences: ^2.0.9
175
176dev_dependencies:
177 flutter_test:
178 sdk: flutter
179
180 flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185 assets:
186 - assets/images/
187
188 uses-material-design: true
189
Can anyone help me understand what is the issue here?
ANSWER
Answered 2021-Dec-25 at 09:13UPDATE:
For your firebase_core
version is seems to be sufficient to pass the FirebaseOptions
once you initialize firebase in your flutter code (and you don't need any script tags in your index.html
):
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161 sdk: ">=2.15.0-268.18.beta <3.0.0"
162
163dependencies:
164 flutter:
165 sdk: flutter
166
167
168 # The following adds the Cupertino Icons font to your application.
169 # Use with the CupertinoIcons class for iOS style icons.
170 cupertino_icons: ^1.0.2
171 firebase_auth: ^3.3.0
172 firebase_core: ^1.10.2
173 google_sign_in: ^5.2.1
174 shared_preferences: ^2.0.9
175
176dev_dependencies:
177 flutter_test:
178 sdk: flutter
179
180 flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185 assets:
186 - assets/images/
187
188 uses-material-design: true
189void main() async {
190 WidgetsFlutterBinding.ensureInitialized();
191 await Firebase.initializeApp(
192 // Replace with actual values
193 options: FirebaseOptions(
194 apiKey: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202
Alternatively, one can also follow the updated official documentation and use the Firebase CLI to automatically create a firebase_options.dart
file in your lib
folder that will define the correct FirebaseOptions
for you. The steps are:
- Install Flutterfire CLI:
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161 sdk: ">=2.15.0-268.18.beta <3.0.0"
162
163dependencies:
164 flutter:
165 sdk: flutter
166
167
168 # The following adds the Cupertino Icons font to your application.
169 # Use with the CupertinoIcons class for iOS style icons.
170 cupertino_icons: ^1.0.2
171 firebase_auth: ^3.3.0
172 firebase_core: ^1.10.2
173 google_sign_in: ^5.2.1
174 shared_preferences: ^2.0.9
175
176dev_dependencies:
177 flutter_test:
178 sdk: flutter
179
180 flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185 assets:
186 - assets/images/
187
188 uses-material-design: true
189void main() async {
190 WidgetsFlutterBinding.ensureInitialized();
191 await Firebase.initializeApp(
192 // Replace with actual values
193 options: FirebaseOptions(
194 apiKey: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203
- Configure Flutterfire (run in your project's root and go through the wizard selecting the correct Firebase project and target platforms):
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161 sdk: ">=2.15.0-268.18.beta <3.0.0"
162
163dependencies:
164 flutter:
165 sdk: flutter
166
167
168 # The following adds the Cupertino Icons font to your application.
169 # Use with the CupertinoIcons class for iOS style icons.
170 cupertino_icons: ^1.0.2
171 firebase_auth: ^3.3.0
172 firebase_core: ^1.10.2
173 google_sign_in: ^5.2.1
174 shared_preferences: ^2.0.9
175
176dev_dependencies:
177 flutter_test:
178 sdk: flutter
179
180 flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185 assets:
186 - assets/images/
187
188 uses-material-design: true
189void main() async {
190 WidgetsFlutterBinding.ensureInitialized();
191 await Firebase.initializeApp(
192 // Replace with actual values
193 options: FirebaseOptions(
194 apiKey: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204
- Import the automatically generated
firebase_options.dart
file in yourmain.dart
file and initializeFirebase
as follows:
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161 sdk: ">=2.15.0-268.18.beta <3.0.0"
162
163dependencies:
164 flutter:
165 sdk: flutter
166
167
168 # The following adds the Cupertino Icons font to your application.
169 # Use with the CupertinoIcons class for iOS style icons.
170 cupertino_icons: ^1.0.2
171 firebase_auth: ^3.3.0
172 firebase_core: ^1.10.2
173 google_sign_in: ^5.2.1
174 shared_preferences: ^2.0.9
175
176dev_dependencies:
177 flutter_test:
178 sdk: flutter
179
180 flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185 assets:
186 - assets/images/
187
188 uses-material-design: true
189void main() async {
190 WidgetsFlutterBinding.ensureInitialized();
191 await Firebase.initializeApp(
192 // Replace with actual values
193 options: FirebaseOptions(
194 apiKey: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204void main() async {
205 WidgetsFlutterBinding.ensureInitialized();
206 await Firebase.initializeApp(
207 options: DefaultFirebaseOptions.currentPlatform,
208 );
209 runApp(MyApp());
210}
211
PREVIOUS ANSWER:
From the docs:
The only way to currently add the Firebase SDKs to your Flutter web project is by importing the scripts from the Firebase content delivery network (CDN).
Therefore, please try to use script tags to import the relevant firebase components with version 8.6.1
as shown below (more info here):
1"FirebaseOptions cannot be null when creating the default app."
2 at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3 at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5 at initializeApp.next (<anonymous>)
6 at http://localhost:7357/dart_sdk.js:40192:33
7 at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8 at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9 at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10 at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11 at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12 at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13 at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14 at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15 at http://localhost:7357/dart_sdk.js:35811:9
16<!DOCTYPE html>
17<html>
18<head>
19 <!--
20 If you are serving your web app in a path other than the root, change the
21 href value below to reflect the base path you are serving from.
22
23 The path provided below has to start and end with a slash "/" in order for
24 it to work correctly.
25
26 For more details:
27 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29 This is a placeholder for base href that will be replaced by the value of
30 the `--base-href` argument provided to `flutter build`.
31 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- This script installs service_worker.js to provide PWA functionality to
52 application. For more information, see:
53 https://developers.google.com/web/fundamentals/primers/service-workers -->
54
55
56 <script>
57 var serviceWorkerVersion = null;
58 var scriptLoaded = false;
59 function loadMainDartJs() {
60 if (scriptLoaded) {
61 return;
62 }
63 scriptLoaded = true;
64 var scriptTag = document.createElement('script');
65 scriptTag.src = 'main.dart.js';
66 scriptTag.type = 'application/javascript';
67 document.body.append(scriptTag);
68 }
69
70 if ('serviceWorker' in navigator) {
71 // Service workers are supported. Use them.
72 window.addEventListener('load', function () {
73 // Wait for registration to finish before dropping the <script> tag.
74 // Otherwise, the browser will load the script multiple times,
75 // potentially different versions.
76 var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77 navigator.serviceWorker.register(serviceWorkerUrl)
78 .then((reg) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (reg.installing || reg.waiting)) {
88 // No active web worker and we have installed or are installing
89 // one for the first time. Simply wait for it to activate.
90 waitForActivation(reg.installing || reg.waiting);
91 } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92 // When the app updates the serviceWorkerVersion changes, so we
93 // need to ask the service worker to update.
94 console.log('New service worker available.');
95 reg.update();
96 waitForActivation(reg.installing);
97 } else {
98 // Existing service worker is still good.
99 console.log('Loading app from service worker.');
100 loadMainDartJs();
101 }
102 });
103
104 // If service worker doesn't succeed in a reasonable amount of time,
105 // fallback to plaint <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
124 // TODO: Add SDKs for Firebase products that you want to use
125 // https://firebase.google.com/docs/web/setup#available-libraries
126
127 // Your web app's Firebase configuration
128 // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129 const firebaseConfig = {
130 apiKey: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161 sdk: ">=2.15.0-268.18.beta <3.0.0"
162
163dependencies:
164 flutter:
165 sdk: flutter
166
167
168 # The following adds the Cupertino Icons font to your application.
169 # Use with the CupertinoIcons class for iOS style icons.
170 cupertino_icons: ^1.0.2
171 firebase_auth: ^3.3.0
172 firebase_core: ^1.10.2
173 google_sign_in: ^5.2.1
174 shared_preferences: ^2.0.9
175
176dev_dependencies:
177 flutter_test:
178 sdk: flutter
179
180 flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185 assets:
186 - assets/images/
187
188 uses-material-design: true
189void main() async {
190 WidgetsFlutterBinding.ensureInitialized();
191 await Firebase.initializeApp(
192 // Replace with actual values
193 options: FirebaseOptions(
194 apiKey: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204void main() async {
205 WidgetsFlutterBinding.ensureInitialized();
206 await Firebase.initializeApp(
207 options: DefaultFirebaseOptions.currentPlatform,
208 );
209 runApp(MyApp());
210}
211 <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
212 <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>
213 <script>
214 var firebaseConfig = {
215 apiKey: "xxx",
216 authDomain: "xxx",
217 projectId: "xx",
218 storageBucket: "exxx",
219 messagingSenderId: "xxx",
220 appId: "xxx",
221 measurementId: "xxx"
222 };
223
224 firebase.initializeApp(firebaseConfig);
225 firebase.analytics();
226 </script>
227
QUESTION
Activiti 6.0.0 UI app / in-memory H2 database in tomcat9 / java version "9.0.1"
Asked 2021-Dec-16 at 09:41I just downloaded activiti-app from github.com/Activiti/Activiti/releases/download/activiti-6.0.0/…
and deployed in tomcat9, but I have this errors when init the app:
1 11:29:40,090 [http-nio-8080-exec-8] INFO org.activiti.app.conf.AsyncConfiguration - Creating Async Task Executor
211:29:40,887 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Configuring Datasource
311:29:40,910 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Configuring Datasource with following properties (omitted password for security)
411:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - datasource driver: org.h2.Driver
511:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - datasource url : jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1
611:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - datasource user name : sa
711:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Min pool size | Max pool size | acquire increment : 10 | 100 | 5
811:29:40,947 [http-nio-8080-exec-8] INFO com.mchange.v2.log.MLog - MLog clients using log4j logging.
911:29:41,014 [http-nio-8080-exec-8] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
1011:29:41,290 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Configuring EntityManager
1111:29:42,220 [http-nio-8080-exec-8] INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge0wdal156qsqtw1cxe|70e1a94b, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.h2.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0wdal156qsqtw1cxe|70e1a94b, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 1800, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {password=******, user=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> true, testConnectionOnCheckout -> true, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
1211:29:43,183 [http-nio-8080-exec-8] ERROR org.activiti.app.conf.SecurityConfiguration - Could not configure authentication mechanism:
13org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbAuthenticationProvider' defined in class path resource [org/activiti/app/conf/SecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationProvider]: Circular reference involving containing bean 'securityConfiguration' - consider declaring the factory method as static for independence from its containing instance. Factory method 'dbAuthenticationProvider' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.activiti.app.service.api.UserCache org.activiti.app.security.UserDetailsService.userCache; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userCacheImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.activiti.engine.IdentityService org.activiti.app.service.idm.UserCacheImpl.identityService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activitiEngineConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.transaction.PlatformTransactionManager org.activiti.app.conf.ActivitiEngineConfiguration.transactionManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'annotationDrivenTransactionManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
14 at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
15 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
16 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
17 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
18 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
19 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
20 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
21 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
22 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
23 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:322)
24 at org.activiti.app.conf.SecurityConfiguration$$EnhancerBySpringCGLIB$$e6992200.dbAuthenticationProvider(<generated>)
25 at org.activiti.app.conf.SecurityConfiguration.configureGlobal(SecurityConfiguration.java:74)
26 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
27 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
28 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
29 at java.base/java.lang.reflect.Method.invoke(Method.java:564)
30 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:642)
31 at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
32 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
33 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
34 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
35 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
36 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
37 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
38 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
39 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
40 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
41 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
42 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
43 at org.activiti.app.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:62)
44 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4768)
45 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230)
46 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
47 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
48 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
49 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
50 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)
51 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:544)
52 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1690)
53 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
54 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
55 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
56 at java.base/java.lang.reflect.Method.invoke(Method.java:564)
57 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:293)
58 at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
59 at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
60 at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1614)
61 at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:292)
62 at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:210)
63 at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
64 at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
65 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
66 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
67 at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:211)
68 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
69 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
70 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
71 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
72 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
73 at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)
74 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
75 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
76 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
77 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
78 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:659)
79 at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:378)
80 at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:56)
81 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
82 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
83 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
84 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
85 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
86 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
87 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
88 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
89 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)
90 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
91 at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
92 at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
93 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
94 at java.base/java.lang.Thread.run(Thread.java:844)
95Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationProvider]: Circular reference involving containing bean 'securityConfiguration' - consider declaring the factory method as static for independence from its containing instance. Factory method 'dbAuthenticationProvider' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.activiti.app.service.api.UserCache org.activiti.app.security.UserDetailsService.userCache; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userCacheImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.activiti.engine.IdentityService org.activiti.app.service.idm.UserCacheImpl.identityService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activitiEngineConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.transaction.PlatformTransactionManager org.activiti.app.conf.ActivitiEngineConfiguration.transactionManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'annotationDrivenTransactionManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
96 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
97 at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
98 ... 80 more
99
and here my activiti-app.properties file:
1 11:29:40,090 [http-nio-8080-exec-8] INFO org.activiti.app.conf.AsyncConfiguration - Creating Async Task Executor
211:29:40,887 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Configuring Datasource
311:29:40,910 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Configuring Datasource with following properties (omitted password for security)
411:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - datasource driver: org.h2.Driver
511:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - datasource url : jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1
611:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - datasource user name : sa
711:29:40,911 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Min pool size | Max pool size | acquire increment : 10 | 100 | 5
811:29:40,947 [http-nio-8080-exec-8] INFO com.mchange.v2.log.MLog - MLog clients using log4j logging.
911:29:41,014 [http-nio-8080-exec-8] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
1011:29:41,290 [http-nio-8080-exec-8] INFO org.activiti.app.conf.DatabaseConfiguration - Configuring EntityManager
1111:29:42,220 [http-nio-8080-exec-8] INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge0wdal156qsqtw1cxe|70e1a94b, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.h2.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0wdal156qsqtw1cxe|70e1a94b, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 1800, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {password=******, user=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> true, testConnectionOnCheckout -> true, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
1211:29:43,183 [http-nio-8080-exec-8] ERROR org.activiti.app.conf.SecurityConfiguration - Could not configure authentication mechanism:
13org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbAuthenticationProvider' defined in class path resource [org/activiti/app/conf/SecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationProvider]: Circular reference involving containing bean 'securityConfiguration' - consider declaring the factory method as static for independence from its containing instance. Factory method 'dbAuthenticationProvider' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.activiti.app.service.api.UserCache org.activiti.app.security.UserDetailsService.userCache; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userCacheImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.activiti.engine.IdentityService org.activiti.app.service.idm.UserCacheImpl.identityService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activitiEngineConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.transaction.PlatformTransactionManager org.activiti.app.conf.ActivitiEngineConfiguration.transactionManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'annotationDrivenTransactionManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
14 at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
15 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
16 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
17 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
18 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
19 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
20 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
21 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
22 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
23 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:322)
24 at org.activiti.app.conf.SecurityConfiguration$$EnhancerBySpringCGLIB$$e6992200.dbAuthenticationProvider(<generated>)
25 at org.activiti.app.conf.SecurityConfiguration.configureGlobal(SecurityConfiguration.java:74)
26 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
27 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
28 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
29 at java.base/java.lang.reflect.Method.invoke(Method.java:564)
30 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:642)
31 at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
32 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
33 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
34 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
35 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
36 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
37 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
38 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
39 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
40 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
41 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
42 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
43 at org.activiti.app.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:62)
44 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4768)
45 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230)
46 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
47 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
48 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
49 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
50 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)
51 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:544)
52 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1690)
53 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
54 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
55 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
56 at java.base/java.lang.reflect.Method.invoke(Method.java:564)
57 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:293)
58 at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
59 at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
60 at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1614)
61 at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:292)
62 at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:210)
63 at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
64 at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
65 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
66 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
67 at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:211)
68 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
69 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
70 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
71 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
72 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
73 at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)
74 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
75 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
76 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
77 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
78 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:659)
79 at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:378)
80 at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:56)
81 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
82 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
83 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
84 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
85 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
86 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
87 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
88 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
89 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)
90 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
91 at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
92 at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
93 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
94 at java.base/java.lang.Thread.run(Thread.java:844)
95Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationProvider]: Circular reference involving containing bean 'securityConfiguration' - consider declaring the factory method as static for independence from its containing instance. Factory method 'dbAuthenticationProvider' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.activiti.app.service.api.UserCache org.activiti.app.security.UserDetailsService.userCache; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userCacheImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.activiti.engine.IdentityService org.activiti.app.service.idm.UserCacheImpl.identityService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activitiEngineConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.transaction.PlatformTransactionManager org.activiti.app.conf.ActivitiEngineConfiguration.transactionManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'annotationDrivenTransactionManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/activiti/app/conf/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
96 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
97 at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
98 ... 80 more
99#
100# SECURITY
101#
102security.rememberme.key=testkey
103
104#
105# DATABASE
106#
107
108datasource.driver=org.h2.Driver
109datasource.url=jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1
110
111#datasource.driver=com.mysql.jdbc.Driver
112#datasource.url=jdbc:mysql://127.0.0.1:3306/activiti6ui?characterEncoding=UTF-8
113
114datasource.username=sa
115datasource.password=
116
117hibernate.dialect=org.hibernate.dialect.H2Dialect
118#hibernate.dialect=org.hibernate.dialect.MySQLDialect
119#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
120#hibernate.dialect=org.hibernate.dialect.SQLServerDialect
121#hibernate.dialect=org.hibernate.dialect.DB2Dialect
122#hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
123
124#
125# EMAIL
126#
127
128#email.enabled=true
129#email.host=localhost
130#email.port=1025
131#email.useCredentials=false
132#email.username=
133#email.password=
134
135# The base url that will be used to create urls in emails.
136#email.base.url=http://localhost:9999/activiti-app
137
138#email.from.default=no-reply@activiti.alfresco.com
139#email.from.default.name=Activiti
140#email.feedback.default=activiti@alfresco.com
141
142#
143# ACTIVITI
144#
145
146activiti.process-definitions.cache.max=500
147
148#
149# DEFAULT ADMINISTRATOR ACCOUNT
150#
151
152admin.email=admin
153admin.password=test
154admin.lastname=Administrator
155
156admin.group=Superusers
157
158# The maximum file upload limit. Set to -1 to set to 'no limit'. Expressed in bytes
159file.upload.max.size=104857600
160
161# For development purposes, data folder is created inside the sources ./data folder
162contentstorage.fs.rootFolder=data/
163contentstorage.fs.createRoot=true
164contentstorage.fs.depth=4
165contentstorage.fs.blockSize=1024
166
ANSWER
Answered 2021-Dec-16 at 09:41Your title says you are using Java 9. With Activiti 6 you will have to use JDK 1.8 (Java 8).
QUESTION
I worked on a private repo in GitHub then made it public. Can I make my activity visible?
Asked 2021-Nov-14 at 16:23I had a private repo for 6 months that I worked on. Today I finally made it public after submitting a paper. Is it possible to make the activity (those green square) visible? I tried clicking on contribution setting
and got the message Visitors will now see your public and anonymized private contributions
, but the activity still doesn't show.
Update 1:
I noticed that only changes I did on GitHub (the website rather than pushing code from my machine) were recorded. That is, only the readme
file shows as I often updated it on the website.
Update 2:
I ran git --no-pager log -s --format="%ae"
to see which emails were used for the commits and got the following:
Some emails are the primary
email under GitHub, some are of the form 43555163+Penguin@users.noreply.github.com
, some are Penguin@Penguin-MacBook-Pro.local
, some are Penguin@econ2-204-32-dhcp.int.university_name.edu
.
Also, as I mentioned in one of the comments below, if I go to my repo and specifically look at commits I can see something like: Penguin authored and Penguin committed on May 27 1 parent 1d71ac3 commit cb95c2870de67383ee653849b4c7b40a062f5fd3
. But this does not show on my activity.
Lastly, some comments mentioned creating a new repo on GitHub and pushing my previous commits (after filtering the emails somehow which I didn't quite understand). However, I already have several Stargazers
on this repo and would like to keep them. By making a new repo I believe these will disappear.
Update 3:
I used git filter-repo
to change all the emails to my primary email and now all my previous commits emails appear to be my primary email when I call git --no-pager log -s --format="%ae"
. However, I still don't see the activity showing. For example, if I go to my repo I can see that one of the commits says Penguin authored and Penguin committed on Apr 8
, but this doesn't show in the activity.
ANSWER
Answered 2021-Oct-11 at 22:43Contributions should still be shown in that case. Here are some of the reasons your contributions might not be being shown:
GitHub isn't aware of the email address you used in your commit messages
The commit wasn't made in the default or gh-pages branch
The repo is a forked repo, not a standalone repo
GitHub also mentions that it will not show commits that were made less than 24 hours ago, so it seems like they have some sort of caching mechanism going on with their contribution graph. It may help to wait 24 hours since you made the repo public, to ensure that cache has a chance to roll over.
QUESTION
How do I run multiple sites on the same server using docker and nginx?
Asked 2021-Oct-16 at 04:29I'm trying to run two sites on django on the same server under different ip, an error occurs that the port is busy, I fixed the ports, but the site does not start. Tell me where is the error please? Ip work, when I go to the second ip I get redirects to the first site. All settings were specified for the second site. At the end, I added the nginx setting of the first site
This is the second docker-compose file and its settings. I would be very grateful for your help
.env
1#Django
2# Should be one of dev, prod
3MODE=prod
4PORT=8008
5
6#postgres
7DB_NAME=xxx
8DB_USER=xxx
9DB_HOST=xxx
10DB_PASSWORD=xxxx
11DB_PORT=5432
12POSTGRES_PASSWORD=mysecretpassword
13
14#WSGI
15WSGI_PORT=8008
16WSGI_WORKERS=4
17WSGI_LOG_LEVEL=debug
18
19# Celery
20CELERY_NUM_WORKERS=2
21
22# Email
23EMAIL_HOST_USER=xxxx
24EMAIL_HOST_PASSWORD=xxxx
25
docker-compose.yml
1#Django
2# Should be one of dev, prod
3MODE=prod
4PORT=8008
5
6#postgres
7DB_NAME=xxx
8DB_USER=xxx
9DB_HOST=xxx
10DB_PASSWORD=xxxx
11DB_PORT=5432
12POSTGRES_PASSWORD=mysecretpassword
13
14#WSGI
15WSGI_PORT=8008
16WSGI_WORKERS=4
17WSGI_LOG_LEVEL=debug
18
19# Celery
20CELERY_NUM_WORKERS=2
21
22# Email
23EMAIL_HOST_USER=xxxx
24EMAIL_HOST_PASSWORD=xxxx
25version: '3'
26
27services:
28
29 backend:
30 build: ./
31 container_name: site_container
32 restart: always
33 command: ./commands/start_server.sh
34 ports:
35 - "${PORT}:${WSGI_PORT}"
36 volumes:
37 - ./src:/srv/project/src
38 - ./commands:/srv/project/commands
39 - static_content:/var/www/site
40 env_file:
41 - .env
42 depends_on:
43 - postgres
44
45 postgres:
46 image: postgres:12
47 volumes:
48 - pg_data:/var/lib/postgresql/data
49 env_file:
50 - .env
51# environment:
52# - DJANGO_SETTINGS_MODULE=app.settings.${MODE}
53
54 nginx:
55 image: nginx:1.19
56 volumes:
57 - ./nginx:/etc/nginx/conf.d
58 - static_content:/var/www/site
59 ports:
60 - 81:80
61 - 444:443
62 env_file:
63 - .env
64 depends_on:
65 - backend
66
67volumes:
68 pg_data: {}
69 static_content: {}
70
default.conf
1#Django
2# Should be one of dev, prod
3MODE=prod
4PORT=8008
5
6#postgres
7DB_NAME=xxx
8DB_USER=xxx
9DB_HOST=xxx
10DB_PASSWORD=xxxx
11DB_PORT=5432
12POSTGRES_PASSWORD=mysecretpassword
13
14#WSGI
15WSGI_PORT=8008
16WSGI_WORKERS=4
17WSGI_LOG_LEVEL=debug
18
19# Celery
20CELERY_NUM_WORKERS=2
21
22# Email
23EMAIL_HOST_USER=xxxx
24EMAIL_HOST_PASSWORD=xxxx
25version: '3'
26
27services:
28
29 backend:
30 build: ./
31 container_name: site_container
32 restart: always
33 command: ./commands/start_server.sh
34 ports:
35 - "${PORT}:${WSGI_PORT}"
36 volumes:
37 - ./src:/srv/project/src
38 - ./commands:/srv/project/commands
39 - static_content:/var/www/site
40 env_file:
41 - .env
42 depends_on:
43 - postgres
44
45 postgres:
46 image: postgres:12
47 volumes:
48 - pg_data:/var/lib/postgresql/data
49 env_file:
50 - .env
51# environment:
52# - DJANGO_SETTINGS_MODULE=app.settings.${MODE}
53
54 nginx:
55 image: nginx:1.19
56 volumes:
57 - ./nginx:/etc/nginx/conf.d
58 - static_content:/var/www/site
59 ports:
60 - 81:80
61 - 444:443
62 env_file:
63 - .env
64 depends_on:
65 - backend
66
67volumes:
68 pg_data: {}
69 static_content: {}
70server {
71 listen 80 default_server;
72
73 server_name 183.22.332.12;
74
75 location /static/ {
76 root /var/www/site;
77 }
78
79 location /media/ {
80 root /var/www/site;
81 }
82
83 location / {
84 proxy_set_header Host $host;
85 proxy_pass http://backend:8010;
86 }
87}
88
default.conf for first site
1#Django
2# Should be one of dev, prod
3MODE=prod
4PORT=8008
5
6#postgres
7DB_NAME=xxx
8DB_USER=xxx
9DB_HOST=xxx
10DB_PASSWORD=xxxx
11DB_PORT=5432
12POSTGRES_PASSWORD=mysecretpassword
13
14#WSGI
15WSGI_PORT=8008
16WSGI_WORKERS=4
17WSGI_LOG_LEVEL=debug
18
19# Celery
20CELERY_NUM_WORKERS=2
21
22# Email
23EMAIL_HOST_USER=xxxx
24EMAIL_HOST_PASSWORD=xxxx
25version: '3'
26
27services:
28
29 backend:
30 build: ./
31 container_name: site_container
32 restart: always
33 command: ./commands/start_server.sh
34 ports:
35 - "${PORT}:${WSGI_PORT}"
36 volumes:
37 - ./src:/srv/project/src
38 - ./commands:/srv/project/commands
39 - static_content:/var/www/site
40 env_file:
41 - .env
42 depends_on:
43 - postgres
44
45 postgres:
46 image: postgres:12
47 volumes:
48 - pg_data:/var/lib/postgresql/data
49 env_file:
50 - .env
51# environment:
52# - DJANGO_SETTINGS_MODULE=app.settings.${MODE}
53
54 nginx:
55 image: nginx:1.19
56 volumes:
57 - ./nginx:/etc/nginx/conf.d
58 - static_content:/var/www/site
59 ports:
60 - 81:80
61 - 444:443
62 env_file:
63 - .env
64 depends_on:
65 - backend
66
67volumes:
68 pg_data: {}
69 static_content: {}
70server {
71 listen 80 default_server;
72
73 server_name 183.22.332.12;
74
75 location /static/ {
76 root /var/www/site;
77 }
78
79 location /media/ {
80 root /var/www/site;
81 }
82
83 location / {
84 proxy_set_header Host $host;
85 proxy_pass http://backend:8010;
86 }
87}
88server {
89 #listen 80 default_server;
90 listen 443 ssl http2;
91 listen [::]:443 ssl http2;
92
93 server_name site1 ip_site1;
94
95 ssl_certificate /etc/letsencrypt/live/site1/fullchain.pem;
96 ssl_certificate_key /etc/letsencrypt/live/site1/privkey.pem;
97 ssl_trusted_certificate /etc/letsencrypt/live/site1/chain.pem;
98
99 location /static/ {
100 root /var/www/artads;
101 }
102
103 location /media/ {
104 root /var/www/artads;
105 }
106
107 location / {
108 proxy_set_header Host $host;
109 proxy_pass http://backend:8008;
110 }
111}
112
113server {
114 listen 80 default_server;
115
116 server_name ip_site2 site2;
117
118 location /static/ {
119 root /var/www/gdr_mr;
120 }
121
122 location /media/ {
123 root /var/www/gdr_mr;
124 }
125
126 location / {
127 proxy_set_header Host $host;
128 proxy_pass http://backend:8013;
129 }
130}
131
132server {
133 listen 80;
134 listen [::]:80;
135
136 server_name www.site1 site1;
137
138 location / {
139 return 301 https://site1$request_uri;
140 }
141}
142
ANSWER
Answered 2021-Sep-22 at 21:54If you're running two virtual servers with different IPs on the same machine, you'd want to specify the IP address in the listen directive:
1#Django
2# Should be one of dev, prod
3MODE=prod
4PORT=8008
5
6#postgres
7DB_NAME=xxx
8DB_USER=xxx
9DB_HOST=xxx
10DB_PASSWORD=xxxx
11DB_PORT=5432
12POSTGRES_PASSWORD=mysecretpassword
13
14#WSGI
15WSGI_PORT=8008
16WSGI_WORKERS=4
17WSGI_LOG_LEVEL=debug
18
19# Celery
20CELERY_NUM_WORKERS=2
21
22# Email
23EMAIL_HOST_USER=xxxx
24EMAIL_HOST_PASSWORD=xxxx
25version: '3'
26
27services:
28
29 backend:
30 build: ./
31 container_name: site_container
32 restart: always
33 command: ./commands/start_server.sh
34 ports:
35 - "${PORT}:${WSGI_PORT}"
36 volumes:
37 - ./src:/srv/project/src
38 - ./commands:/srv/project/commands
39 - static_content:/var/www/site
40 env_file:
41 - .env
42 depends_on:
43 - postgres
44
45 postgres:
46 image: postgres:12
47 volumes:
48 - pg_data:/var/lib/postgresql/data
49 env_file:
50 - .env
51# environment:
52# - DJANGO_SETTINGS_MODULE=app.settings.${MODE}
53
54 nginx:
55 image: nginx:1.19
56 volumes:
57 - ./nginx:/etc/nginx/conf.d
58 - static_content:/var/www/site
59 ports:
60 - 81:80
61 - 444:443
62 env_file:
63 - .env
64 depends_on:
65 - backend
66
67volumes:
68 pg_data: {}
69 static_content: {}
70server {
71 listen 80 default_server;
72
73 server_name 183.22.332.12;
74
75 location /static/ {
76 root /var/www/site;
77 }
78
79 location /media/ {
80 root /var/www/site;
81 }
82
83 location / {
84 proxy_set_header Host $host;
85 proxy_pass http://backend:8010;
86 }
87}
88server {
89 #listen 80 default_server;
90 listen 443 ssl http2;
91 listen [::]:443 ssl http2;
92
93 server_name site1 ip_site1;
94
95 ssl_certificate /etc/letsencrypt/live/site1/fullchain.pem;
96 ssl_certificate_key /etc/letsencrypt/live/site1/privkey.pem;
97 ssl_trusted_certificate /etc/letsencrypt/live/site1/chain.pem;
98
99 location /static/ {
100 root /var/www/artads;
101 }
102
103 location /media/ {
104 root /var/www/artads;
105 }
106
107 location / {
108 proxy_set_header Host $host;
109 proxy_pass http://backend:8008;
110 }
111}
112
113server {
114 listen 80 default_server;
115
116 server_name ip_site2 site2;
117
118 location /static/ {
119 root /var/www/gdr_mr;
120 }
121
122 location /media/ {
123 root /var/www/gdr_mr;
124 }
125
126 location / {
127 proxy_set_header Host $host;
128 proxy_pass http://backend:8013;
129 }
130}
131
132server {
133 listen 80;
134 listen [::]:80;
135
136 server_name www.site1 site1;
137
138 location / {
139 return 301 https://site1$request_uri;
140 }
141}
142server {
143 listen 192.168.1.1:80;
144 server_name example.net www.example.net;
145 ...
146}
147
148server {
149 listen 192.168.1.2:80;
150 server_name example.com www.example.com;
151 ...
152}
153
More on how nginx
processes requests can be found here: http://nginx.org/en/docs/http/request_processing.html
QUESTION
Default route always execute in react router
Asked 2021-Oct-06 at 21:10I am working on a project where I am using the strikingDash template. Here I face some issues of routing while changing the routes from URL.
auth.js
1import React, { lazy, Suspense } from "react"
2import { Spin } from "antd"
3import { Switch, Route, Redirect } from "react-router-dom"
4import AuthLayout from "../container/profile/authentication/Index"
5
6const Login = lazy(() =>
7 import("../container/profile/authentication/overview/SignIn")
8)
9const SignUp = lazy(() =>
10 import("../container/profile/authentication/overview/SignUp")
11)
12const ForgetPassword = lazy(() =>
13 import("../container/profile/authentication/overview/ForgetPassword")
14)
15const EmailConfirmation = lazy(() =>
16 import("../container/profile/authentication/overview/EmailConfirmation")
17)
18const VerificationPage = lazy(() =>
19 import("../container/profile/authentication/overview/VerificationPage")
20)
21
22const NotFound = () => {
23 console.log("NOT FOUND")
24 return <Redirect to="/" />
25}
26
27const FrontendRoutes = () => {
28 return (
29 <Switch>
30 <Suspense
31 fallback={
32 <div className="spin">
33 <Spin />
34 </div>
35 }
36 >
37 <Route exact path="/verification" component={VerificationPage} />
38 <Route exact path="/email-confirmation" component={EmailConfirmation} />
39 <Route exact path="/forgetPassword" component={ForgetPassword} />
40 <Route exact path="/signup" component={SignUp} />
41 <Route exact path="/" component={Login} />
42 <Route component={NotFound} />
43 </Suspense>
44 </Switch>
45 )
46}
47
48export default AuthLayout(FrontendRoutes)
49
App.js
1import React, { lazy, Suspense } from "react"
2import { Spin } from "antd"
3import { Switch, Route, Redirect } from "react-router-dom"
4import AuthLayout from "../container/profile/authentication/Index"
5
6const Login = lazy(() =>
7 import("../container/profile/authentication/overview/SignIn")
8)
9const SignUp = lazy(() =>
10 import("../container/profile/authentication/overview/SignUp")
11)
12const ForgetPassword = lazy(() =>
13 import("../container/profile/authentication/overview/ForgetPassword")
14)
15const EmailConfirmation = lazy(() =>
16 import("../container/profile/authentication/overview/EmailConfirmation")
17)
18const VerificationPage = lazy(() =>
19 import("../container/profile/authentication/overview/VerificationPage")
20)
21
22const NotFound = () => {
23 console.log("NOT FOUND")
24 return <Redirect to="/" />
25}
26
27const FrontendRoutes = () => {
28 return (
29 <Switch>
30 <Suspense
31 fallback={
32 <div className="spin">
33 <Spin />
34 </div>
35 }
36 >
37 <Route exact path="/verification" component={VerificationPage} />
38 <Route exact path="/email-confirmation" component={EmailConfirmation} />
39 <Route exact path="/forgetPassword" component={ForgetPassword} />
40 <Route exact path="/signup" component={SignUp} />
41 <Route exact path="/" component={Login} />
42 <Route component={NotFound} />
43 </Suspense>
44 </Switch>
45 )
46}
47
48export default AuthLayout(FrontendRoutes)
49import React, { useEffect, useState } from "react";
50import { hot } from "react-hot-loader/root";
51import { Provider, useSelector } from "react-redux";
52import { ThemeProvider } from "styled-components";
53import { BrowserRouter as Router, Redirect, Route } from "react-router-dom";
54import { ConfigProvider } from "antd";
55import store from "./redux/store";
56import Admin from "./routes/admin";
57import Auth from "./routes/auth";
58import "./static/css/style.css";
59import config from "./config/config";
60import ProtectedRoute from "./components/utilities/protectedRoute";
61
62const { theme } = config;
63
64const ProviderConfig = () => {
65 const { rtl, isLoggedIn, topMenu, darkMode } = useSelector(state => {
66 return {
67 darkMode: state.ChangeLayoutMode.data,
68 rtl: state.ChangeLayoutMode.rtlData,
69 topMenu: state.ChangeLayoutMode.topMenu,
70 isLoggedIn: state.Authentication.login,
71 };
72 });
73
74 const [path, setPath] = useState(window.location.pathname);
75
76 useEffect(() => {
77 let unmounted = false;
78 if (!unmounted) {
79 setPath(window.location.pathname);
80 }
81 // eslint-disable-next-line no-return-assign
82 return () => (unmounted = true);
83 }, [setPath]);
84
85 return (
86 <ConfigProvider direction={rtl ? "rtl" : "ltr"}>
87 <ThemeProvider theme={{ ...theme, rtl, topMenu, darkMode }}>
88 <Router basename={process.env.PUBLIC_URL}>
89 {!isLoggedIn ? <>{console.log("INSIDE PUBLIC")}<Route path="/" component={Auth} /></> : <ProtectedRoute path="/admin" component={Admin} />}
90 {isLoggedIn && (path === process.env.PUBLIC_URL || path === `${process.env.PUBLIC_URL}/`) && (
91 <Redirect to="/admin" />
92 )}
93 </Router>
94 </ThemeProvider>
95 </ConfigProvider>
96 );
97};
98
99function App() {
100 return (
101 <Provider store={store}>
102 <ProviderConfig />
103 </Provider>
104 );
105}
106
107export default hot(App);
108
Whenever I change the URL to another route as I described above in Frontend Routes. Then it will always print console statements like these:
1import React, { lazy, Suspense } from "react"
2import { Spin } from "antd"
3import { Switch, Route, Redirect } from "react-router-dom"
4import AuthLayout from "../container/profile/authentication/Index"
5
6const Login = lazy(() =>
7 import("../container/profile/authentication/overview/SignIn")
8)
9const SignUp = lazy(() =>
10 import("../container/profile/authentication/overview/SignUp")
11)
12const ForgetPassword = lazy(() =>
13 import("../container/profile/authentication/overview/ForgetPassword")
14)
15const EmailConfirmation = lazy(() =>
16 import("../container/profile/authentication/overview/EmailConfirmation")
17)
18const VerificationPage = lazy(() =>
19 import("../container/profile/authentication/overview/VerificationPage")
20)
21
22const NotFound = () => {
23 console.log("NOT FOUND")
24 return <Redirect to="/" />
25}
26
27const FrontendRoutes = () => {
28 return (
29 <Switch>
30 <Suspense
31 fallback={
32 <div className="spin">
33 <Spin />
34 </div>
35 }
36 >
37 <Route exact path="/verification" component={VerificationPage} />
38 <Route exact path="/email-confirmation" component={EmailConfirmation} />
39 <Route exact path="/forgetPassword" component={ForgetPassword} />
40 <Route exact path="/signup" component={SignUp} />
41 <Route exact path="/" component={Login} />
42 <Route component={NotFound} />
43 </Suspense>
44 </Switch>
45 )
46}
47
48export default AuthLayout(FrontendRoutes)
49import React, { useEffect, useState } from "react";
50import { hot } from "react-hot-loader/root";
51import { Provider, useSelector } from "react-redux";
52import { ThemeProvider } from "styled-components";
53import { BrowserRouter as Router, Redirect, Route } from "react-router-dom";
54import { ConfigProvider } from "antd";
55import store from "./redux/store";
56import Admin from "./routes/admin";
57import Auth from "./routes/auth";
58import "./static/css/style.css";
59import config from "./config/config";
60import ProtectedRoute from "./components/utilities/protectedRoute";
61
62const { theme } = config;
63
64const ProviderConfig = () => {
65 const { rtl, isLoggedIn, topMenu, darkMode } = useSelector(state => {
66 return {
67 darkMode: state.ChangeLayoutMode.data,
68 rtl: state.ChangeLayoutMode.rtlData,
69 topMenu: state.ChangeLayoutMode.topMenu,
70 isLoggedIn: state.Authentication.login,
71 };
72 });
73
74 const [path, setPath] = useState(window.location.pathname);
75
76 useEffect(() => {
77 let unmounted = false;
78 if (!unmounted) {
79 setPath(window.location.pathname);
80 }
81 // eslint-disable-next-line no-return-assign
82 return () => (unmounted = true);
83 }, [setPath]);
84
85 return (
86 <ConfigProvider direction={rtl ? "rtl" : "ltr"}>
87 <ThemeProvider theme={{ ...theme, rtl, topMenu, darkMode }}>
88 <Router basename={process.env.PUBLIC_URL}>
89 {!isLoggedIn ? <>{console.log("INSIDE PUBLIC")}<Route path="/" component={Auth} /></> : <ProtectedRoute path="/admin" component={Admin} />}
90 {isLoggedIn && (path === process.env.PUBLIC_URL || path === `${process.env.PUBLIC_URL}/`) && (
91 <Redirect to="/admin" />
92 )}
93 </Router>
94 </ThemeProvider>
95 </ConfigProvider>
96 );
97};
98
99function App() {
100 return (
101 <Provider store={store}>
102 <ProviderConfig />
103 </Provider>
104 );
105}
106
107export default hot(App);
108INSIDE PUBLIC
109NOT FOUND
110INSIDE PUBLIC
111NOT FOUND
112
Expected Behaviour: Whenever I update the URL it will render the component according to the switch case and return it back
Actual Behaviour: Whenever I update the URL it will render the component as well as the default component. I think Switch here renders multiple components, but I don't know why.
ANSWER
Answered 2021-Sep-13 at 12:51The problem should be in the order of your pages: the root path works as a collector of all the pages, you should try to add the exact
keyword to the Router path. Here the reference for the differences between the different notations.
1import React, { lazy, Suspense } from "react"
2import { Spin } from "antd"
3import { Switch, Route, Redirect } from "react-router-dom"
4import AuthLayout from "../container/profile/authentication/Index"
5
6const Login = lazy(() =>
7 import("../container/profile/authentication/overview/SignIn")
8)
9const SignUp = lazy(() =>
10 import("../container/profile/authentication/overview/SignUp")
11)
12const ForgetPassword = lazy(() =>
13 import("../container/profile/authentication/overview/ForgetPassword")
14)
15const EmailConfirmation = lazy(() =>
16 import("../container/profile/authentication/overview/EmailConfirmation")
17)
18const VerificationPage = lazy(() =>
19 import("../container/profile/authentication/overview/VerificationPage")
20)
21
22const NotFound = () => {
23 console.log("NOT FOUND")
24 return <Redirect to="/" />
25}
26
27const FrontendRoutes = () => {
28 return (
29 <Switch>
30 <Suspense
31 fallback={
32 <div className="spin">
33 <Spin />
34 </div>
35 }
36 >
37 <Route exact path="/verification" component={VerificationPage} />
38 <Route exact path="/email-confirmation" component={EmailConfirmation} />
39 <Route exact path="/forgetPassword" component={ForgetPassword} />
40 <Route exact path="/signup" component={SignUp} />
41 <Route exact path="/" component={Login} />
42 <Route component={NotFound} />
43 </Suspense>
44 </Switch>
45 )
46}
47
48export default AuthLayout(FrontendRoutes)
49import React, { useEffect, useState } from "react";
50import { hot } from "react-hot-loader/root";
51import { Provider, useSelector } from "react-redux";
52import { ThemeProvider } from "styled-components";
53import { BrowserRouter as Router, Redirect, Route } from "react-router-dom";
54import { ConfigProvider } from "antd";
55import store from "./redux/store";
56import Admin from "./routes/admin";
57import Auth from "./routes/auth";
58import "./static/css/style.css";
59import config from "./config/config";
60import ProtectedRoute from "./components/utilities/protectedRoute";
61
62const { theme } = config;
63
64const ProviderConfig = () => {
65 const { rtl, isLoggedIn, topMenu, darkMode } = useSelector(state => {
66 return {
67 darkMode: state.ChangeLayoutMode.data,
68 rtl: state.ChangeLayoutMode.rtlData,
69 topMenu: state.ChangeLayoutMode.topMenu,
70 isLoggedIn: state.Authentication.login,
71 };
72 });
73
74 const [path, setPath] = useState(window.location.pathname);
75
76 useEffect(() => {
77 let unmounted = false;
78 if (!unmounted) {
79 setPath(window.location.pathname);
80 }
81 // eslint-disable-next-line no-return-assign
82 return () => (unmounted = true);
83 }, [setPath]);
84
85 return (
86 <ConfigProvider direction={rtl ? "rtl" : "ltr"}>
87 <ThemeProvider theme={{ ...theme, rtl, topMenu, darkMode }}>
88 <Router basename={process.env.PUBLIC_URL}>
89 {!isLoggedIn ? <>{console.log("INSIDE PUBLIC")}<Route path="/" component={Auth} /></> : <ProtectedRoute path="/admin" component={Admin} />}
90 {isLoggedIn && (path === process.env.PUBLIC_URL || path === `${process.env.PUBLIC_URL}/`) && (
91 <Redirect to="/admin" />
92 )}
93 </Router>
94 </ThemeProvider>
95 </ConfigProvider>
96 );
97};
98
99function App() {
100 return (
101 <Provider store={store}>
102 <ProviderConfig />
103 </Provider>
104 );
105}
106
107export default hot(App);
108INSIDE PUBLIC
109NOT FOUND
110INSIDE PUBLIC
111NOT FOUND
112<Route exact path="/" component={Login} />
113
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Email
Tutorials and Learning Resources are not available at this moment for Email