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

form-components/form-components.js?id= ERR_ABORTED 404 #72

Closed
magarrent opened this issue Jan 11, 2023 · 2 comments
Closed

form-components/form-components.js?id= ERR_ABORTED 404 #72

magarrent opened this issue Jan 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@magarrent
Copy link
Contributor

magarrent commented Jan 11, 2023

Laravel Form Components Version

^7.1

Laravel Version

9.19

Alpine Version

3.10

Bug description

In a production environment not found the form-components.js file, and nothing works:

I don't know why but it works locally. I'm using Vite. Locally works with npm run dev and build

I don't see in the Docs if I have to publish something, I use @fcStyles and @fcScripts correctly...
Did I miss something? I'm the only one?

Steps to reproduce

No response

Relevant log output

GET /form-components/form-components.js?id=03553f899311a06c3381 404
players:1 Refused to execute script from '/form-components/form-components.js?id=03553f899311a06c3381' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
@magarrent magarrent added the bug Something isn't working label Jan 11, 2023
@magarrent
Copy link
Contributor Author

Hmmm okay, after all morning trying to find out what happened...

I noticed that the 404 was an NGINX 404, not a laravel, so the request never arrived to the laravel application.

The reason:
In my /etc/nginx/nginxconfig.io/general.conf I configured a cache for assets:

# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
    expires 7d;
}

The JS URL ends in .js so that's why it never ends in the laravel application and stops in the Nginx.

@rawilk I think we should think about changing the way the package loads that js, maybe include in the Vite.js and compile it? Something like this?

@rawilk
Copy link
Owner

rawilk commented Mar 14, 2023

The package handles this file the same way that Laravel Livewire handles its JS file that it loads. As far as I know, there shouldn't be any issues hitting the controller for that route unless your server isn't configured correctly. Personally, I haven't had any issues with it like this.

If you have issues with the external script loading, you could stop trying to load it with the @fcJavaScript directive, and instead import the source into your own js and compile it that way, but that's a measure that shouldn't ordinarily have to be taken.

@rawilk rawilk closed this as completed Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants