import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [{ path: '/:pathMatch(.*)', redirect: '/auth' }]
})

router.beforeEach((to, from, next) => {
  const nextUrl = to.query.rd || to.query.service || to.query.redirect_uri || to.query.next_url
  nextUrl && window.localStorage.setItem('next_url', nextUrl)
  next()
})

export default router
