Nuxt Proxy - ChoDragon9/posts GitHub Wiki
nuxt.config.ts μ€μ κ°
@nuxtjs/proxy
λͺ¨λμ μ¬μ©νλ©΄ λ‘컬 κ°λ° νκ²½μ Proxyλ₯Ό μ€μ ν μ μλ€.
μ리λ μ΄λ λ€. http://localhost:3000μ ν΄λΌμ΄μΈνΈ μλ²κ° λμ΄μ Έ μλ€λ©΄ API μμ² μ http://localhost:3000μ μμ²νλ€. μμ²νλ©΄ Proxy μλ²κ° API μλ²μ HTTP μμ²μ ν΄μ€λ€.
http Proxy μ€μ
proxy: process.env.PROXY
? ['http://service-api-sandbox.domain.com/api']
: []
https Proxy μ€μ
μΈμ¦μ λ°κΈ: https://blog.lael.be/post/7147
{
modules: ['@nuxtjs/proxy'],
proxy: process.env.PROXY
? {
'/api': {
target: {
host: 'service-api-sandbox.domain.com',
protocol: 'https:',
port: 443
},
secure: false,
changeOrigin: true,
logLevel: 'info'
}
}
: [],
server: process.env.PROXY
? {
https: {
key: fs.readFileSync(path.resolve(__dirname, 'localhost.key')),
cert: fs.readFileSync(path.resolve(__dirname, 'localhost.crt'))
}
}
: {}
}