0

I've created a tiny droplet as a staging system for my project. It's Laravel 9 + inertiajs all using vite.

I've encountered this weird issue where I get the following CORS errors:

test-123:1 Access to script at 'http://[::1]:5173/@vite/client' from origin 'http://xxx' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
test-123:18          GET http://[::1]:5173/@vite/client net::ERR_FAILED
test-123:1 Access to script at 'http://[::1]:5173/resources/js/app.js' from origin 'http://xxx' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
test-123:18          GET http://[::1]:5173/resources/js/app.js net::ERR_FAILED
test-123:1 Access to script at 'http://[::1]:5173/resources/js/Pages/GoalNotAvailable.vue' from origin 'http://xxx' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
test-123:18          GET http://[::1]:5173/resources/js/Pages/GoalNotAvailable.vue net::ERR_FAILED

Locally for development, I am using Laravel sail however here I just installed it directly on the server.

I have default CORS settings in Laravel seeing as this is testing. I also tried to do reverse proxy thinking that this might help but of course, it did not.

Does anyone have any idea what I need to do to essentially run a dev version of my app on droplet?

I understand why I am getting CORS issues but I can't see why if that makes sense as the settings seem to be correct.

Robert
  • 1,206
  • 1
  • 17
  • 33
  • Does this answer your question? [CORS error on request to localhost dev server from remote site](https://stackoverflow.com/questions/66534759/cors-error-on-request-to-localhost-dev-server-from-remote-site) – zanderwar Jan 14 '23 at 14:14
  • @zanderwar that is actually really bad advice as they just suggest to switch off security settings and the whole thing is using webpack and I am using vite, on the top of that it's not about assets but more and about understanding what are the correct steps to fixing the issue as well as what is the problem rather than temporary workaround. – Robert Jan 14 '23 at 14:18
  • My feelings: – zanderwar Jan 14 '23 at 14:41
  • In your case I think it's the vite development server that needs to be configured for CORS, not the PHP (laravel) bit of the app, though it should be by default it may need extra config if your paths are non-default – apokryfos Jan 14 '23 at 19:08

0 Answers0