Commit 87bde002 by Hao-Hsiang Song

added cors

parents cdb7dc29 c55e3d0f
.idea/
*.iml
.DS_Store
node_modules
target
# Created by https://www.gitignore.io/api/intellij
# Edit at https://www.gitignore.io/?templates=intellij
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "spring-data-rest-and-reactjs",
"version": "0.1.0",
"description": "Demo of ReactJS + Spring Data REST",
"repository": {
"type": "git",
"url": "git@github.com:spring-guides/tut-react-and-spring-data-rest.git"
},
"keywords": [
"rest",
"hateoas",
"spring",
"data",
"react"
],
"author": "Greg L. Turnquist",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/spring-guides/tut-react-and-spring-data-rest/issues"
},
"homepage": "https://github.com/spring-guides/tut-react-and-spring-data-rest",
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2",
"rest": "^1.3.1"
},
"scripts": {
"watch": "webpack --watch -d"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.0"
}
}
......@@ -15,15 +15,52 @@
*/
package edu.uchicago.mpcs.topics;
import edu.uchicago.mpcs.topics.auction.Item;
import edu.uchicago.mpcs.topics.controller.ItemController;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
// tag::code[]
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
SpringApplication.run(Application.class, args);
}
@Bean
public CommandLineRunner run(ApplicationContext appContext) {
return args -> {
ItemController itemController = appContext.getBean(ItemController.class);
for (int i=0; i<5; i++) {
Item item = new Item(
"title" + i,
"desc" + i,
(long) i,
5.0,
500.0,
"https://www.sprint.com/content/dam/sprint/commerce/devices/apple/iphone_xr/red/devicenb_650x900.png/jcr:content/renditions/cq5dam.thumbnail.290.370.png",
(long) i
);
itemController.addItem(item);
System.out.println(i);
}
};
}
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("http://localhost:3000");
}
};
}
}
// end::code[]
\ No newline at end of file
......@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Created by Bright on 2018-11-17.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "spring-data-rest-and-reactjs",
"name": "react-shopping-cart",
"version": "0.1.0",
"description": "Demo of ReactJS + Spring Data REST",
"description": "Shopping cart",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"cors": "^2.8.5",
"express": "^4.16.4",
"node-sass-chokidar": "^1.3.4",
"react": "^16.6.1",
"react-dom": "^16.6.1",
"react-redux": "^5.1.1",
"react-scripts": "^1.1.5",
"redux": "^3.7.2",
"redux-thunk": "^2.3.0"
},
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"server": "nodemon server.js"
},
"repository": {
"type": "git",
"url": "git@github.com:spring-guides/tut-react-and-spring-data-rest.git"
"url": "git+https://github.com/jeffersonRibeiro/react-shopping-cart.git"
},
"keywords": [
"rest",
"hateoas",
"spring",
"data",
"react"
"React",
"eCommerce"
],
"author": "Greg L. Turnquist",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/spring-guides/tut-react-and-spring-data-rest/issues"
},
"homepage": "https://github.com/spring-guides/tut-react-and-spring-data-rest",
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2",
"rest": "^1.3.1"
"author": "Jefferson Ribeiro",
"license": "MIT",
"devDependencies": {
"nodemon": "^1.18.6"
},
"scripts": {
"watch": "webpack --watch -d"
"bugs": {
"url": "https://github.com/jeffersonRibeiro/react-shopping-cart/issues"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.0"
}
"homepage": "https://react-shopping-cart-67954.firebaseapp.com/"
}
mvn package && java -jar target/topics-auction-0.0.1-SNAPSHOT.jar
\ No newline at end of file
var path = require('path');
module.exports = {
entry: './src/main/js/app.js',
devtool: 'sourcemaps',
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/bundle.js'
},
module: {
rules: [
{
test: path.join(__dirname, '.'),
exclude: /(node_modules)/,
use: [{
loader: 'babel-loader',
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}]
}
]
}
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment