Feat: 使用代理API绕开Cookie跨域限制

This commit is contained in:
HFO4 2019-11-29 15:30:01 +08:00
parent 5d91aaf44d
commit cc79470bd4
5 changed files with 21 additions and 12 deletions

View File

@ -83,6 +83,12 @@ module.exports = function(proxy, allowedHost) {
},
public: allowedHost,
proxy,
proxy: {
'/api': {
target: 'http://localhost:5000',
secure: false
}
},
before(app, server) {
if (fs.existsSync(paths.proxySetup)) {
// This registers user provided middleware for proxy reasons

View File

@ -30,7 +30,7 @@ import LinkIcon from '@material-ui/icons/InsertLink'
import DeleteIcon from '@material-ui/icons/Delete'
import OpenIcon from '@material-ui/icons/OpenInNew'
import {MagnetOn} from 'mdi-material-ui'
import {baseURL} from "../../middleware/Api"
import { withStyles, Popover, Typography, MenuList, MenuItem, Divider, ListItemIcon } from '@material-ui/core';
const styles = theme => ({
@ -124,7 +124,7 @@ class ContextMenuCompoment extends Component {
}
this.props.changeContextMenu("file",false);
let downloadPath = this.props.selected[0].path === "/" ? this.props.selected[0].path+this.props.selected[0].name:this.props.selected[0].path+"/"+this.props.selected[0].name;
window.open(window.apiURL.download+"?action=download&path="+encodeURIComponent(downloadPath));
window.open(baseURL+"/file"+(downloadPath));
}

View File

@ -234,14 +234,17 @@ class NavigatorCompoment extends Component {
}
checkOverFlow = ()=>{
const hasOverflowingChildren = this.element.current.offsetHeight < this.element.current.scrollHeight ||
this.element.current.offsetWidth < this.element.current.scrollWidth;
if(hasOverflowingChildren && !this.state.hiddenMode){
this.setState({hiddenMode:true});
}
if(!hasOverflowingChildren && this.state.hiddenMode){
this.setState({hiddenMode:false});
if (this.element.current !== null){
const hasOverflowingChildren = this.element.current.offsetHeight < this.element.current.scrollHeight ||
this.element.current.offsetWidth < this.element.current.scrollWidth;
if(hasOverflowingChildren && !this.state.hiddenMode){
this.setState({hiddenMode:true});
}
if(!hasOverflowingChildren && this.state.hiddenMode){
this.setState({hiddenMode:false});
}
}
}
navigateTo=(event,id)=> {

View File

@ -56,7 +56,6 @@ class UploaderCompoment extends Component {
loaded = true;
var user = Auth.GetUser();
window.uploadConfig = user.policy;
console.log(window.uploadConfig);
this.uploader = window.Qiniu.uploader({
runtimes: "html5",
browse_button: "pickfiles",
@ -84,7 +83,6 @@ class UploaderCompoment extends Component {
window.pathCache[files.id] = this.props.path;
this.fileList["enQueue"](files);
});
console.log(window.pathCache);
},
BeforeUpload: function(up, file) {},

View File

@ -1,8 +1,10 @@
import axios from "axios";
import Auth from "./Auth"
export const baseURL = "/api/v3";
const instance = axios.create({
baseURL: "http://127.0.0.1:5000/api/v3",
baseURL: baseURL,
withCredentials: true,
crossDomain: true,
});