serve api on same origin at /api
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const webpack = require('webpack');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
const env = dotenv.config({ path: path.resolve(__dirname, '.env.local') }).parsed || {};
|
||||
|
||||
const DEFAULT_DEV_API = 'http://127.0.0.1:3000';
|
||||
|
||||
const API_BASE_URL = env.API_BASE_URL || process.env.API_BASE_URL || DEFAULT_DEV_API;
|
||||
|
||||
module.exports = {
|
||||
entry: './src/index.jsx',
|
||||
output: {
|
||||
@@ -46,9 +37,6 @@ module.exports = {
|
||||
template: path.resolve(__dirname, 'src/index.html'),
|
||||
favicon: false,
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.API_BASE_URL': JSON.stringify(API_BASE_URL),
|
||||
}),
|
||||
],
|
||||
devServer: {
|
||||
static: {
|
||||
@@ -58,6 +46,14 @@ module.exports = {
|
||||
port: 5173,
|
||||
historyApiFallback: true,
|
||||
open: true,
|
||||
proxy: [
|
||||
{
|
||||
context: ['/api'],
|
||||
target: 'http://127.0.0.1:3000',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
devtool: 'source-map',
|
||||
resolve: {
|
||||
|
||||
Reference in New Issue
Block a user