I've been trying to build an interia app with capacitor. Using the Laravel vue starter kit for testing. After authenticating the router.visit example command below doesn't do anything as I can't render the Dashboard. I do see the request for /dashboard being made to the server, but the view remains as the Login. Works just fine as a SPA web app. I saw in #💬-general history @glacial ermine got this to work a long time ago but I'm stuck trying to get any page to render past the first login screen.
axios.post(url, {email: form.email, password: form.password})
.then((response) => {
Preferences.set({ key: 'auth_token', value: response.data });
console.log(route('dashboard'));
router.get(route('dashboard')); // makes req. but does not render
}).catch((error) => {
console.log('error');
console.log(error);
});
And I modified axios to handle requests in capacitor
class AxiosBootstrap {
static async setupRouter() {
const storedToken = await Preferences.get({ key: 'auth_token' });
router.on('before', (event) => {
if (Capacitor.isNativePlatform()) {
const visit = event.detail.visit;
visit.url.host = '192.168.3.119';
visit.url.protocol = 'http';
visit.url.port = '8000';
if (storedToken.value) {
axios.defaults.headers.common['Authorization'] = 'Bearer ' + storedToken.value;
}
}
});
if (Capacitor.isNativePlatform()) {
axios.defaults.baseURL = 'http://192.168.3.119:8000';
axios.defaults.withCredentials = true;
axios.defaults.withXSRFToken = true;
}
}