Last active
July 16, 2022 21:48
-
-
Save stctheproducer/deee28001e12b01dc4b8113416229e2e to your computer and use it in GitHub Desktop.
Nuxt Custom Configurations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto from 'crypto' | |
export default { | |
publicRuntimeConfig: { | |
appName: process.env.APP_NAME, | |
baseUrl: process.env.BASE_URL, | |
apiUrl: process.env.API_URL, | |
authUrl: process.env.AUTH_URL, | |
oauthClientId: process.env.FUSIONAUTH_CLIENT_ID, | |
oauthTenantId: process.env.FUSIONAUTH_TENANT_ID, | |
flutterwavePublicKey: process.env.FLW_PUBLIC_KEY, | |
}, | |
privateRuntimeConfig: { | |
oauthClientSecret: process.env.FUSIONAUTH_CLIENT_SECRET, | |
}, | |
server: { | |
host: '0.0.0.0', | |
port: 3001 | |
}, | |
// Auth module configuration | |
auth: { | |
defaultStrategy: 'fusionauth', | |
cookie: { | |
prefix: 'auth.', | |
options: { | |
path: '/', | |
secure: false, | |
}, | |
}, | |
scopeKey: 'roles', | |
redirect: { | |
login: '/', | |
logout: false, | |
callback: '/', | |
home: '/dashboard', | |
}, | |
strategies: { | |
fusionauth: { | |
_scheme: 'oauth2', | |
authorization_endpoint: `${process.env.AUTH_URL}/oauth2/authorize`, | |
userinfo_endpoint: `${process.env.AUTH_URL}/oauth2/userinfo`, | |
scope: ['offline_access'], | |
access_type: 'offline', | |
access_token_endpoint: `${process.env.API_URL}/oauth2/token`, | |
response_type: 'code', | |
token_type: 'Bearer', | |
client_id: `${process.env.FUSIONAUTH_CLIENT_ID}`, | |
tenantId: `${process.env.FUSIONAUTH_TENANT_ID}`, | |
token_key: 'access_token', | |
refresh_token_key: 'refresh_token', | |
state: crypto.randomBytes(16).toString('hex'), | |
}, | |
}, | |
}, | |
// Axios module configuration (https://go.nuxtjs.dev/config-axios) | |
proxy: { | |
'/api/': { target: process.env.API_URL, pathRewrite: { '^/api/': '' } }, | |
}, | |
axios: { | |
proxy: true, | |
// https: true, | |
baseURL: process.env.API_URL, | |
}, | |
build: { | |
extend(config, ctx) { | |
// Run ESLint on save | |
// yarn add -D eslint-loader | |
if (ctx.isDev && ctx.isClient) { | |
config.module.rules.push({ | |
enforce: 'pre', | |
test: /\.(js|vue)$/, | |
loader: 'eslint-loader', | |
exclude: /(node_modules)/, | |
options: { | |
fix: true, | |
}, | |
}) | |
} | |
}, | |
}, | |
router: { | |
middleware: ['auth'], | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment