Skip to content

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/.env". HTTP request succeeded, but the server responded with HTTP status 404. #95

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

Closed
YawarOsman opened this issue Jan 11, 2024 · 6 comments

Comments

@YawarOsman
Copy link

When i try to load my .env file it shows this error:

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/.env". HTTP request succeeded, but the server responded with HTTP status 404.

I have added this too:

  assets:
    - .env
@nghiashiyi
Copy link

When i try to load my .env file it shows this error:

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/.env". HTTP request succeeded, but the server responded with HTTP status 404.

I have added this too:

  assets:
    - .env

Same issue

@MilanHofmann
Copy link

Same for me.

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/dotenv". HTTP request succeeded, but the server responded with HTTP status 404.

But my flutter web service worker has "assets/assets/dotenv": "4ef2f78446edff171436088341b541e3" in it's resources...?

@wj-yang-pro
Copy link

Same here,

I found that changing the file name to 'env' works on firebase web projects

https://{host}/assets/.env -> http 404
https://{host}/assets/env -> http 200

not sure if it is a firebase hosting problem

overall, I need to change
env filename: .env to env
pubspec.yaml

  assets:
    - env

and
code:

await dotevn.load(fileName: 'env')

@heki-dm
Copy link

heki-dm commented Oct 23, 2024

I encountered the same problem.

There was a hidden file setting in firebase.json, so I tried excluding it, but the result was the same.
However, I don't know if the setting method is correct.

Before

  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",  // include .env file?
      "**/node_modules/**"
    ]
  }

After

  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "!.env",  // add
      "**/node_modules/**"
    ]
  }

@ayaosama14
Copy link

Same for me.

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/name.json". HTTP request succeeded, but the server responded with HTTP status 404.

@lmanliang
Copy link

Files that start with a dot (.) are considered a security concern on most web servers, such as Apache and Nginx, and access is typically restricted. This is not an issue with Flutter dotenv, but rather a default limitation of the web server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants