mirror of
https://github.com/actix/examples
synced 2024-11-30 17:14:35 +01:00
commit
26f7c40d5e
@ -10,6 +10,6 @@ $ cargo run
|
||||
```bash
|
||||
$ cd web-cors/frontend
|
||||
$ npm install
|
||||
$ npm run dev
|
||||
$ npm run serve
|
||||
```
|
||||
then open browser 'http://localhost:1234/'
|
||||
then open browser 'http://localhost:8080'
|
||||
|
@ -15,7 +15,7 @@ fn main() -> std::io::Result<()> {
|
||||
App::new()
|
||||
.wrap(
|
||||
Cors::new()
|
||||
.allowed_origin("http://localhost:1234")
|
||||
.allowed_origin("http://localhost:8080")
|
||||
.allowed_methods(vec!["GET", "POST"])
|
||||
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
|
||||
.allowed_header(header::CONTENT_TYPE)
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"presets": ["env"]
|
||||
}
|
1
web-cors/frontend/.gitignore
vendored
1
web-cors/frontend/.gitignore
vendored
@ -5,6 +5,7 @@ node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
package-lock.json
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
|
@ -7,7 +7,5 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./src/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
7407
web-cors/frontend/package-lock.json
generated
7407
web-cors/frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,16 @@
|
||||
{
|
||||
"name": "actix-web-cors",
|
||||
"name": "frontend-vue",
|
||||
"version": "0.1.0",
|
||||
"description": "webapp",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "rm -rf dist/ && NODE_ENV=development parcel index.html",
|
||||
"build": "NODE_ENV=production parcel build index.html",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"vue": "^2.5.13",
|
||||
"vue-router": "^3.0.1",
|
||||
"axios": "^0.17.1"
|
||||
"vue": "2.6.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"parcel-bundler": "^1.4.1",
|
||||
"parcel-plugin-vue": "^1.5.0"
|
||||
"@vue/cli-service": "^3.0.0",
|
||||
"vue-template-compiler": "^2.5.21"
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
export default {
|
||||
name: 'app',
|
||||
data () {
|
||||
@ -39,24 +38,30 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
signup () {
|
||||
var username = this.Username
|
||||
var email = this.Email
|
||||
var password = this.Password
|
||||
var confirm_password = this.ConfirmPassword
|
||||
console.log(email)
|
||||
axios.post('http://localhost:8000/user/info', {
|
||||
let username = this.Username
|
||||
let email = this.Email
|
||||
let password = this.Password
|
||||
let confirm_password = this.ConfirmPassword
|
||||
let data = {
|
||||
username: username,
|
||||
email: email,
|
||||
password: password,
|
||||
confirm_password: confirm_password
|
||||
}
|
||||
fetch('http://localhost:8000/user/info', {
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
method: 'POST',
|
||||
}).then(response => response.json())
|
||||
.then(json => {
|
||||
console.log(json)
|
||||
this.email = json.email
|
||||
this.username = json.username
|
||||
this.password = json.password
|
||||
})
|
||||
.then(response => {
|
||||
console.log(response.data)
|
||||
this.email = response.data.email
|
||||
this.username = response.data.username
|
||||
this.password = response.data.password
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
@ -95,7 +100,6 @@ input[type="password"] {
|
||||
border-radius: 2px;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
transition: 0.1s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -2,10 +2,5 @@ import Vue from 'vue'
|
||||
import App from './app'
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
render: h => h(App)
|
||||
})
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept();
|
||||
}
|
||||
}).$mount('#app')
|
||||
|
Loading…
Reference in New Issue
Block a user