I'm new to Stack Overflow, I'm new to Vue.js, so please forgive me if I'm doing something wrong in advance :)
I'm building an application that has only main component, which is in my root directory (/index.html). Based on a name passed to the path, this component loads a json with the same name and serves the SPA based on it (important: it does not render the pure json, it uses the json to mount a SPA and this part is working fine). So the paths could be any of the following (they're always dynamic):
http://my-example-site.s3-website-sa-east-1.amazonaws.com/*foo*
http://my-example-site.s3-website-sa-east-1.amazonaws.com/*bar*
http://my-example-site.s3-website-sa-east-1.amazonaws.com/*anotherfoo*
http://my-example-site.s3-website-sa-east-1.amazonaws.com/*anotherbarandsoon*
It works fine when I run on dev, but when I build it to S3 I get a 404 saying that it can't find "foo" path. The fastest workaround was to set my error page to "index.html" on S3, but of course this isn't a good idea as I always get a 404 (the page renders correctly though, even if I don't get a 200 or alike)
I did some research (maybe not enough, sorry :() and found this code:
const router = new VueRouter({
base: __dirname,
mode:'history',
routes: [
{
path: '*',
redirect: '/index.html'
}
]
});
var vm = new Vue({
router,
el: '#app',
render: h => h(App)
});
global.vm = vm;
I get no compilation errors and it runs fine... until I put it on S3. Same problem then: 404.
So, the question is: what am I doing wrong?