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'))
        }
      }
    : {}
}