Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load Amplify Auth Plugin inside a Embedded Flutter Web App #5421

Open
2 of 14 tasks
solarsiva opened this issue Sep 3, 2024 · 3 comments
Open
2 of 14 tasks
Labels
auth Issues related to the Auth Category pending-community-response Pending response from the issue opener or other community members question A question about the Amplify Flutter libraries

Comments

@solarsiva
Copy link

solarsiva commented Sep 3, 2024

Description

When I load a embedded Web App with the Amplify plugin, I am getting an error loading Amplify Auth Plugin.

The error I see is

workers.min.js:1 Uncaught SyntaxError: Unexpected token '<' (at workers.min.js:1:1)

And when I try to look at the file, this file is loaded from Web root context and hence the library could not be loaded. The path I see is https://localhost:3000/....../test/packages/amplify_auth_cognito_dart/src/workers/workers.release.dart.js

This is breaking the Amplify Auth inside the Flutter Embedded Web App.

The same error is not happening when trying to host the full flutter app in Amplify hosting. Please look in to this and suggest a solution.

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Build the flutter app using the command flutter build web --web-renderer canvaskit --release --target=lib/main.dart

  2. Copy the build/web contents and paste it inside public folder of react application

  3. Load the Flutter inside React component using
    if (window._flutter && window._flutter.loader) {
    window._flutter.loader.loadEntrypoint({
    entrypointUrl: "/flutter/main.dart.js",

     		onEntrypointLoaded: (engineInitializer) => {
     			engineInitializer
     				.initializeEngine({
     					hostElement: target,
     					assetBase: "/flutter/",
     				})
     				.then((appRunner) => {
     					console.log("App Runner", appRunner);
     					appRunner.runApp();
     					setTimeout(() => {
     						initialized(true);
     					}, 1000);
     				});
     		},
     	});
    

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.22.2

Amplify Flutter Version

2.4.0

Deployment Method

Amplify Gen 2

Schema

No response

@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Sep 3, 2024
@solarsiva
Copy link
Author

Screenshot 2024-09-03 at 12 42 59 AM

@NikaHsn
Copy link
Member

NikaHsn commented Sep 3, 2024

@solarsiva Sorry that you are facing this issue and thanks for reporting it. We will look into this and get back to you when we have updates.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Sep 3, 2024
@NikaHsn NikaHsn added the auth Issues related to the Auth Category label Sep 3, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Sep 6, 2024

@solarsiva do you serve your web app from the root path? if not you may need to update the base path of your flutter web app define in /web/index.html.

@NikaHsn NikaHsn added question A question about the Amplify Flutter libraries pending-community-response Pending response from the issue opener or other community members and removed pending-triage This issue is in the backlog of issues to triage labels Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth Category pending-community-response Pending response from the issue opener or other community members question A question about the Amplify Flutter libraries
Projects
None yet
Development

No branches or pull requests

2 participants