Silverstripe RESTful service API cross origin Access-Control-Allow-Origin issue

Add below to index.php for test if ( strpos($_SERVER[‘REQUEST_URI’], ‘/api/v1/’ ) !== false ){ // only allow GET, OPTIONS for all api header(‘Access-Control-Allow-Origin: *’); header(‘Access-Control-Allow-Methods: GET, OPTIONS’); header(‘Access-Control-Allow-Credentials: true’); header(‘Access-Control-Allow-Headers: Authorization, Content-Type, x-xsrf-token, x_csrftoken, x-csrf-token, x-requested-with, Cache-Control, X-Requested-With, Origin, Accept’); header(‘Content-Type: application/json’); if ($_SERVER[‘REQUEST_METHOD’] === ‘OPTIONS’) { echojson_encode($_SERVER[‘REQUEST_URI’]); exit(); } } // Build request and …

HTML code for the middle dot

There’s actually six variants of this HTML code for the middle dot: char description unicode html html entity utf-8 · Middle Dot U+00B7 · · C2 B7 • Bullet U+2022 • • E2 80 A2 ‧ Hyphenation Point U+2027 ₁ E2 80 A7 ∙ Bullet Operator U+2219 ∙ E2 88 99 ● Black Circle U+25CF …

Install silverstripe4 on mac via composer

composer create–project silverstripe/installer ./my/website/folder Got error: need to install php-intl Solution: change default php7.1 to php7.3 by vi ~/.bash_profile … export PATH=/usr/local/opt/[email protected]/bin:$PATH source ~/.bash_profile now, php -v shows php7.3 php -i | grep intl run composer create–project silverstripe/installer ./my/website/folder again and looks fine Go to http://localhost/install.php shows error says need to set timezone vi php.ini set date.timezone …

How to custom print css via bootstrap

first, use .hidden-print and .visible-print pre-defined class in bootstrap. then @media print { .header{padding:0;} .main-content{padding:0; margin-left:20px;} .recipe_content{width:100%;padding-right:0px;background: rgb(120, 138, 125) !important;} .col-left2 {float:none; width:auto;padding-right:0px;} .main.receipe_detail_wrap{width:auto;} body, html{background: rgb(153, 115, 120) !important;padding:0;margin:0;} } Tips: use background: color !important; for debug use body, html{ padding:0;margin:0;} for strip the unexpected space set default window print margin: @page{ margin-right …

How to add google map javascript api into ReactJS component

To avoid error: You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors You need to remove the google api script in unmount componentDidMount() { const Id = this.props.match.params.id axios.get(`${this.api_basic}/${Id}`, { params: { //limit: 885, } }).then(response => { … this.showGoogleMaps(response.data.data.address) }) } componentWillMount() { // Start …

How to fix Code Helper running at 100% CPU on Mac

VS code uses the file watcher to identify any changes in the files. You can exclude the folders containing multiple files and not require to watch continuously. “files.watcherExclude”: { “**/.git/objects/**”: true, “**/node_modules/**”: true } eg.: “files.watcherExclude”: { “**/.git/objects/**”: true, “**/.git/subtree-cache/**”: true, “**/node_modules/**”: true, “**/mycms1/mycms/application/**”: true, “**/mycms1/mycms/library/**”: true, “**/mycms2/MyCMS2/**”: true, “**/mycms2/MyCMS2-Admin/**”: true }

VueJs/ReactJS await for async axios function get/post method and sleep(n) seconds

Note: you cannot use await unless your function is marked async sleep(ms) { return new Promise(resolve=>setTimeout(resolve, ms)); }, async onSubmit() { this.loading=true; this.reports= []; if ( this.all_builders_selected ){ // NOT GOOD, GOT ERROR 429 (Too Many Requests) for (let [index, builder] ofthis.builders.entries()) { await this.sleep(1000); await this.getOneReport(builder.id); console.log(builder.id, index) //if ( index > 5 ) …