Skip to content

Instantly share code, notes, and snippets.

@codeperl
Created August 18, 2022 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeperl/5ab6d0aafbbf57a6e77349206f7e772e to your computer and use it in GitHub Desktop.
Save codeperl/5ab6d0aafbbf57a6e77349206f7e772e to your computer and use it in GitHub Desktop.
Facing issue to integrate nuxt app and laravel api when they are in different docker container
// FIXME: MOHAMMAD ASHRAFUDDIN FERDOUSI: THIS NUXT URL IS HARDCODED BUT IT'S NOT GUARANTEED THAT EVEN PHONE'S APP WILL USE THE SAME URL!
const BASE_URL = process.env.BASE_URL || 'https://larecom.com:4430';
const API_BASE_URL = 'https://api.laraecom.com/api/v1/';
const HOST_DOCKER_INTERNAL = 'laraecom_backend_local_env_nginx/api/v1';
export default {
generate: {
fallback: true
},
server: {
host: process.env.NUXT_HOST,
port: process.env.NUXT_PORT,
},
// target: 'static', // default is 'server'
// Global page headers (https://go.nuxtjs.dev/config-head)
head: {
title: 'nuxtproj',
titleTemplate: 'nuxtproj | %s',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
],
},
// Global CSS (https://go.nuxtjs.dev/config-css)
css: [
/*"~/node_modules/bootstrap/dist/css/bootstrap.min.css",*/
'~/assets/scss/style.scss',
'~/assets/css/animation.css',
],
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [
'~/plugins/vue-awesome-swiper.js',
'~/plugins/vuejs-pagiante.js',
'~/plugins/observe-visibility.js',
{
src: '~/plugins/bootstrap.js',
mode: 'client'
},
{
src: '~/plugins/vue-js-modal',
mode: 'client'
},
{
src: '~/plugins/notifications-client.js',
mode: 'client'
},
],
env: {
baseUrl: BASE_URL,
apiBaseUrl: API_BASE_URL
},
// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
],
// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
'@nuxtjs/style-resources',
'@nuxtjs/axios',
'@nuxtjs/auth-next'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
// baseUrl: process.env.baseUrl,
// credentials: true,
baseURL: '/',
browserBaseURL: '/',
proxy: true,
credentials: true,
},
proxy: {
// Simple proxy
'/apiv1': { target: API_BASE_URL, pathRewrite: { '^/apiv1': '' } }
},
publicRuntimeConfig: {
axios: {
browserBaseURL: `${BASE_URL}/apiv1`,
},
},
privateRuntimeConfig: {
axios: {
baseURL: HOST_DOCKER_INTERNAL,
},
},
auth: {
strategies: {
social: {
scheme: 'local',
/*url: BASE_URL,*/
url: '/apiv1',
token: {
property: 'data.token',
name: 'Authorization',
type: 'Bearer',
},
user: {
property: false,
},
endpoints: {
login: {
url: `users/auth/social/login`, method: 'post'
},
logout: {
url: `users/auth/logout`, method: 'post'
},
user: {
url: `users/me`, method: 'get'
}
}
}
}
},
router: {
// middleware: ['auth']
},
styleResources: {
scss: [
'~/assets/scss/_variables.scss',
]
},
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
extractCSS: true,
extend (config, ctx) {
},
babel: {
compact: true,
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment