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

__unocss_ready/1639148123556 are not found. #254

Closed
chuoke opened this issue Dec 10, 2021 · 23 comments · Fixed by #368
Closed

__unocss_ready/1639148123556 are not found. #254

chuoke opened this issue Dec 10, 2021 · 23 comments · Fixed by #368

Comments

@chuoke
Copy link

chuoke commented Dec 10, 2021

I use Unocss with Inertiajs and Vite in Laravel. They are running on two different hosts. And I got errors as follows:

http://localhost/__unocss_ready/1639148123556 
404 Not Found

This is the domain name of the master site (Laravel with Inertia), but Vite is on http://localhost:3000.

And I found some code in Unocss

const READY_CALLBACK_DEFAULT = "/__unocss_ready";

I guess that's why it's wrong. Didn't find a way to customize it. Any help?

Btw, That doesn't seem to affect Unocss's work.

@RAGGA-TIME
Copy link

How to resolve?

@buhrmi
Copy link

buhrmi commented Jan 2, 2022

I think the problem is that https://github.com/antfu/unocss/blob/main/packages/vite/src/modes/global/dev.ts#L126 should make a request to vite dev server, but instead its going to the main app server

@RAGGA-TIME
Copy link

RAGGA-TIME commented Jan 2, 2022 via email

@buhrmi
Copy link

buhrmi commented Jan 2, 2022

This happens only if the dev server (./bin/vite dev) is running. FWIW, I'm also using Inertiajs, but with Rails (instead of Laraval) using ViteRuby

@buhrmi
Copy link

buhrmi commented Jan 2, 2022

When using ViteRuby's, the dev server listens under /vite-dev, so this condition can never be true. Maybe @ElMassimo has an idea what to do here 🤔

@ElMassimo
Copy link
Collaborator

ElMassimo commented Jan 2, 2022

@buhrmi The unocss middleware should take the Vite base under account (which should fix this issue).

@userquin
Copy link
Member

userquin commented Jan 2, 2022

I'll fix it: we need to add the base to the generated fetch code.

@chuoke
Copy link
Author

chuoke commented Jan 3, 2022

Thank you @userquin.

Do I only need to update this version? Do I need to modify or add some configurations?

@userquin
Copy link
Member

userquin commented Jan 3, 2022

@chuoke just update , maybe you need to uninstall and install again the dependencies...

@chuoke
Copy link
Author

chuoke commented Jan 3, 2022

@userquin It seems still not working, But it's closer than it was.

And I found this code:

return `${code}\nawait fetch("${base}${READY_CALLBACK_DEFAULT}/${lastServed}")`

I wonder, can change it directly to like this:

return `${code}\nawait fetch("${vite_host}${base}${READY_CALLBACK_DEFAULT}/${lastServed}")`

The vite_host is resolved from vite config like the base.

This can be perfect with my problem.

@userquin
Copy link
Member

userquin commented Jan 3, 2022

@chuoke are you using server.host and server.port in your project? can you share your Vite config file?

@userquin
Copy link
Member

userquin commented Jan 3, 2022

imagen

@userquin
Copy link
Member

userquin commented Jan 3, 2022

The Vite configuration (it is an sveltekit project, just see the server option):

imagen

@userquin
Copy link
Member

userquin commented Jan 3, 2022

@chuoke Upps, you're connecting 2 servers, sorry man, maybe we can include some resolver for the base url, I'll take a look...

@chuoke
Copy link
Author

chuoke commented Jan 3, 2022

Yes, I use them.

"server": {
        "preTransformRequests": true,
        "host": "192.168.56.1",
        "https": false,
        "port": 3000,
        "origin": "http://192.168.56.1:3000",
        "hmr": {
            "host": "192.168.56.1",
            "port": 3000
        },
    },

This is the server part of the runtime configuration that I printed out because part of the configuration is dynamic.

@userquin
Copy link
Member

userquin commented Jan 3, 2022

With previous configuration the inspector should work at http://192.168.56.1:3000/__unocss/ (if you have a base should be http://192.168.56.1:3000/<base>/__unocss/)

If you have another server in front of previous one, you should proxy all request from http://<another_host>:<another_port>/__unocss/* to http://192.168.56.1:3000/__unocss/*. If the front end server is also a vite project it can be done with server.proxy, if you're using another server you should check the docs to do it.

@userquin
Copy link
Member

userquin commented Jan 3, 2022

Sorry again, can you explain a bit your configuration?

EDIT: the app on each server and what's running on each server

@chuoke
Copy link
Author

chuoke commented Jan 3, 2022

I run Vite with Laravel using Inertial Vue3 and Laravel-vite, which did a little bit of processing. And Vite and Laravel running on a different server.

I use a domain for the Laravel app, such as http://my-app.test, which is in the foreground.
Vite just on http://192.168.56.1:3000/build, actually.

The Laravel app is responsible for data processing and by Inertial to tell Vue which component should be rendered. So Vite is like a backroom supporter.

@userquin
Copy link
Member

userquin commented Jan 3, 2022

@chuoke can you provide a minimal repro (gh or starblizt) so I can check it?

@chuoke
Copy link
Author

chuoke commented Jan 3, 2022

Can you use PHP? I have a reproduction: https://github.com/chuoke/laravel-with-inertail-and-vite-error-reproduction ,
After you run all servers, visit Laravel server, you'll see 404 errors like http://127.0.0.1:8000/__unocss_ready/1641225308035 in the console.

@userquin
Copy link
Member

userquin commented Jan 3, 2022

@chuoke I have installed PHP 8.11 and composer but starting the PHP server I have 2 problems: port 8000 cannot be used and once started on 8081 (PHP change the port automatically) then I have an error about encryption not configured.

Can we move here #387? details on the discussion.

@chuoke
Copy link
Author

chuoke commented Feb 10, 2022

🎉 Now, It works. Thank you.

BTW, it released in v0.24.0.

@RAGGA-TIME
Copy link

RAGGA-TIME commented Feb 10, 2022 via email

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

Successfully merging a pull request may close this issue.

5 participants