angular2 http.get无法使用webpack-server代理

时间:2016-07-15 05:01:39

标签: angular proxy webpack

这是我的webpack-server config

public function createOrderAction($paymentMethod) {
    try {
    $checkout_session = Mage::getSingleton('checkout/session');
    $cq = $checkout_session->getQuote();
    $cq->assignCustomer(Mage::getSingleton('customer/session')->getCustomer());
    $quoteObj = Mage::getModel('sales/quote')->load($checkout_session->getQuoteId()); // Mage_Sales_Model_Quote
    //Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()

    $items = $quoteObj->getAllItems();                  

    $quoteObj->reserveOrderId();

      // set payment method 

    $quotePaymentObj = $quoteObj->getPayment(); // Mage_Sales_Model_Quote_Payment
    $quotePaymentObj->setMethod($paymentMethod);

    $quoteObj->setPayment($quotePaymentObj);


    // convert quote to order
    $convertQuoteObj = Mage::getSingleton('sales/convert_quote');

    $quoteObj->setShippingAddress($cq->getShippingAddress());
    $quoteObj->setBillingAddress($cq->getBillingAddress());
    $orderObj = $convertQuoteObj->addressToOrder($quoteObj->getShippingAddress());

    $orderPaymentObj = $convertQuoteObj->paymentToOrderPayment($quotePaymentObj);


    // convert quote addresses
    $orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getBillingAddress()));

    $orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getShippingAddress()));

    // set payment options
    $orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($quoteObj->getPayment()));

    // convert quote items
    foreach ($items as $item) {
        // @var $item Mage_Sales_Model_Quote_Item
        $orderItem = $convertQuoteObj->itemToOrderItem($item);
        $orderItem->setWholesaler($item->getWholesaler());
        $orderItem->setComment($item->getComment());
        $options = array();
        if ($productOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct())) {
            $options = $productOptions;
        }
        if ($addOptions = $item->getOptionByCode('additional_options')) {
            $options['additional_options'] = unserialize($addOptions->getValue());
        }
        if ($options) {
            $orderItem->setProductOptions($options);
        }
        if ($item->getParentItem()) {
            $orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
        }
        $orderObj->addItem($orderItem);
    }
        $orderObj->setCanShipPartiallyItem(false);
        $orderObj->place();
        $quoteObj->setIsActive(0)->save();
        $orderObj->save(); 
        $orderObj->sendNewOrderEmail(); 
        return $orderObj->getId();
    } catch (Exception $e){     
        Mage::log($e->getMessage());
        Mage::log($e->getTraceAsString());
    }
}

和路线代码在这里,与angular2

的doc代码相同
       devServer:{
        proxy: {
            '/open/*': {
                target: 'http://127.0.0.1:3000',
            }
        },
        historyApiFallback: true
    },

我启动服务器没有错误

const routes:RouterConfig = [
{
    path: '',
    redirectTo: '/login',
    pathMatch: 'full'
},
{
    path: 'login',
    component: loginComponent
},

我的HTML代码

70% 3/3 build moduleshttp://localhost:9000/
webpack result is served from http://localhost:9000/
content is served from /Users/atyun/code/weinei-web
404s will fallback to /index.html

这是一个angular2事件按钮

和功能代码

<button type="button" (click)="hello()">hello</button>

我打开浏览器,当我点击按钮时,页面会重新加载,为什么?浏览器控制台有错误,但我看不到它,因为它重新加载速度如此之快。

如何解决?

0 个答案:

没有答案