Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
马贞晓
/
templateReact
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b6656c34
authored
Nov 13, 2019
by
马贞晓
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完成配置
1 parent
2f02f1e7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
config/env.js
config/webpackDevServer.config.js
src/view/index/index.js
config/env.js
View file @
b6656c3
...
...
@@ -50,6 +50,7 @@ dotenvFiles.forEach(dotenvFile => {
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
// We also resolve them to make sure all tools using them work consistently.
const
appDirectory
=
fs
.
realpathSync
(
process
.
cwd
());
process
.
env
.
NODE_PATH
=
(
process
.
env
.
NODE_PATH
||
''
)
.
split
(
path
.
delimiter
)
.
filter
(
folder
=>
folder
&&
!
path
.
isAbsolute
(
folder
))
...
...
config/webpackDevServer.config.js
View file @
b6656c3
...
...
@@ -85,12 +85,14 @@ module.exports = function(proxy, allowedHost) {
public
:
allowedHost
,
proxy
:{
"/api"
:
{
target
:
"http
s://www.jianshu.com/shakespeare/notes/2ce732125376/recommendations
"
,
target
:
"http
://192.168.0.8:8080/
"
,
pathRewrite
:
{
"^/api"
:
""
}
}
},
before
(
app
,
server
)
{
app
.
get
(
'/test'
,
function
(
req
,
res
)
{
res
.
json
({
data
:
'test2'
});
});
// console.log(path.join(__dirname,'../src/service/mock/index.js'))
if
(
fs
.
existsSync
(
paths
.
proxySetup
))
{
// This registers user provided middleware for proxy reasons
...
...
src/view/index/index.js
View file @
b6656c3
...
...
@@ -17,7 +17,14 @@ import $http from "../../service";
componentDidMount
(){
// debugger
console
.
log
(
$http
)
$http
.
GET
(
"/api"
)
$http
.
GET
(
"/test"
)
.
then
(
d
=>
{
debugger
})
.
catch
(
e
=>
{
debugger
})
$http
.
GET
(
"/api/demo"
)
.
then
(
d
=>
{
debugger
})
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment