Spark local development - wrong path in JS 404 error
I'm currently developing an webapp with Spark and have run into a problem I don't know how to fix.
When I enter the register page I see a 404 error in the console "GET XHR http://localhost/geocode/country"
The paths are wrong since they should point to a subfolder.
I've set the APP_URL in the .env to the subfolder at localhost but the requests which lead to the 404s are made from JS files.
How can I get the JS files to use the APP_URL as well?
I haven't found the files yet which make these calls but I don't want to hardcode the URL anyway since it's going to change.
This is where spark tries to figure out your country based on your IP and obviously this does not work for a localhost IP address.
But nevertheless is should not return an error but fall back to the default.
The url is called from here but it normally should have a default to country: US: vendor\laravel\spark\resources\assets\js\auth\register-stripe.js
in the guessCountry() method.
Have you run gulp/ webpack without any errors? On my system in also works on localhost without errors.
What is your folder structure? Depending on the complexity you may need to wrap most url's in {{ url('/') }} or even have a script variable like below in your layouts app file.
Then in your Vue components you can prepend the axios.get calls with App.url to look something like axios.get(App.url + '/my/spark/route'). I have seen some folks do tricks with .htaccess but I have not tried that myself. I just find wrapping the url as a basic behavior guarantees no worries later. Doing this in Spark may break future updates though, so hopefully there is a trick that I am not aware of.
@jlucia I'm pretty sure this would solve the issue, but as you said - future updates may override my customization again.
I guess most people just don't have their installation in a subfolder so they don't encounter this problem, right?
@EventFellows what more would I have to do than dump-autoload?